2013-02-18 15:32:11 +00:00
|
|
|
/* mbed Microcontroller Library
|
|
|
|
* Copyright (c) 2006-2013 ARM Limited
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
#ifndef MBED_FILEBASE_H
|
|
|
|
#define MBED_FILEBASE_H
|
|
|
|
|
|
|
|
typedef int FILEHANDLE;
|
|
|
|
|
2016-09-30 23:32:06 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
2013-02-18 15:32:11 +00:00
|
|
|
|
2016-10-01 07:11:36 +00:00
|
|
|
#include "platform/platform.h"
|
|
|
|
#include "platform/SingletonPtr.h"
|
|
|
|
#include "platform/PlatformMutex.h"
|
2017-06-20 11:47:27 +00:00
|
|
|
#include "platform/NonCopyable.h"
|
2013-02-18 15:32:11 +00:00
|
|
|
|
|
|
|
namespace mbed {
|
2017-10-24 15:05:45 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
typedef enum {
|
|
|
|
FilePathType,
|
|
|
|
FileSystemPathType
|
|
|
|
} PathType;
|
|
|
|
|
2017-10-24 15:05:45 +00:00
|
|
|
/** \addtogroup platform */
|
|
|
|
/** @{*/
|
2017-04-04 19:21:53 +00:00
|
|
|
/**
|
2017-10-24 15:05:45 +00:00
|
|
|
* \defgroup platform_FileBase FileBase class
|
|
|
|
* @{
|
2017-04-04 19:21:53 +00:00
|
|
|
*/
|
2017-10-24 15:05:45 +00:00
|
|
|
/** Class FileBase
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-06-20 11:47:27 +00:00
|
|
|
class FileBase : private NonCopyable<FileBase> {
|
2013-02-18 15:32:11 +00:00
|
|
|
public:
|
|
|
|
FileBase(const char *name, PathType t);
|
|
|
|
virtual ~FileBase();
|
|
|
|
|
|
|
|
const char* getName(void);
|
|
|
|
PathType getPathType(void);
|
|
|
|
|
|
|
|
static FileBase *lookup(const char *name, unsigned int len);
|
|
|
|
|
|
|
|
static FileBase *get(int n);
|
|
|
|
|
2016-05-31 22:57:41 +00:00
|
|
|
/* disallow copy constructor and assignment operators */
|
|
|
|
private:
|
2013-02-18 15:32:11 +00:00
|
|
|
static FileBase *_head;
|
2016-06-27 23:55:07 +00:00
|
|
|
static SingletonPtr<PlatformMutex> _mutex;
|
2013-02-18 15:32:11 +00:00
|
|
|
|
|
|
|
FileBase *_next;
|
2016-05-31 22:57:41 +00:00
|
|
|
const char * const _name;
|
|
|
|
const PathType _path_type;
|
2013-02-18 15:32:11 +00:00
|
|
|
};
|
|
|
|
|
2017-10-24 15:05:45 +00:00
|
|
|
/**@}*/
|
|
|
|
|
|
|
|
/**@}*/
|
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
} // namespace mbed
|
|
|
|
|
|
|
|
#endif
|
2016-10-04 20:02:44 +00:00
|
|
|
|