mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
platform/FileBase.h@178:79309dc6340a, 2017-11-23 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 23 11:57:25 2017 +0000
- Revision:
- 178:79309dc6340a
- Parent:
- 168:9672193075cf
mbed-dev library. Release version 156
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 167:e84263d55307 | 1 | /* mbed Microcontroller Library |
AnnaBridge | 167:e84263d55307 | 2 | * Copyright (c) 2006-2013 ARM Limited |
AnnaBridge | 167:e84263d55307 | 3 | * |
AnnaBridge | 167:e84263d55307 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
AnnaBridge | 167:e84263d55307 | 5 | * you may not use this file except in compliance with the License. |
AnnaBridge | 167:e84263d55307 | 6 | * You may obtain a copy of the License at |
AnnaBridge | 167:e84263d55307 | 7 | * |
AnnaBridge | 167:e84263d55307 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
AnnaBridge | 167:e84263d55307 | 9 | * |
AnnaBridge | 167:e84263d55307 | 10 | * Unless required by applicable law or agreed to in writing, software |
AnnaBridge | 167:e84263d55307 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
AnnaBridge | 167:e84263d55307 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
AnnaBridge | 167:e84263d55307 | 13 | * See the License for the specific language governing permissions and |
AnnaBridge | 167:e84263d55307 | 14 | * limitations under the License. |
AnnaBridge | 167:e84263d55307 | 15 | */ |
AnnaBridge | 167:e84263d55307 | 16 | #ifndef MBED_FILEBASE_H |
AnnaBridge | 167:e84263d55307 | 17 | #define MBED_FILEBASE_H |
AnnaBridge | 167:e84263d55307 | 18 | |
AnnaBridge | 167:e84263d55307 | 19 | typedef int FILEHANDLE; |
AnnaBridge | 167:e84263d55307 | 20 | |
AnnaBridge | 167:e84263d55307 | 21 | #include <cstdio> |
AnnaBridge | 167:e84263d55307 | 22 | #include <cstring> |
AnnaBridge | 167:e84263d55307 | 23 | |
AnnaBridge | 167:e84263d55307 | 24 | #include "platform/platform.h" |
AnnaBridge | 167:e84263d55307 | 25 | #include "platform/SingletonPtr.h" |
AnnaBridge | 167:e84263d55307 | 26 | #include "platform/PlatformMutex.h" |
AnnaBridge | 168:9672193075cf | 27 | #include "platform/NonCopyable.h" |
AnnaBridge | 167:e84263d55307 | 28 | |
AnnaBridge | 167:e84263d55307 | 29 | namespace mbed { |
AnnaBridge | 178:79309dc6340a | 30 | |
AnnaBridge | 167:e84263d55307 | 31 | typedef enum { |
AnnaBridge | 167:e84263d55307 | 32 | FilePathType, |
AnnaBridge | 167:e84263d55307 | 33 | FileSystemPathType |
AnnaBridge | 167:e84263d55307 | 34 | } PathType; |
AnnaBridge | 167:e84263d55307 | 35 | |
AnnaBridge | 178:79309dc6340a | 36 | /** \addtogroup platform */ |
AnnaBridge | 178:79309dc6340a | 37 | /** @{*/ |
AnnaBridge | 167:e84263d55307 | 38 | /** |
AnnaBridge | 178:79309dc6340a | 39 | * \defgroup platform_FileBase FileBase class |
AnnaBridge | 178:79309dc6340a | 40 | * @{ |
AnnaBridge | 167:e84263d55307 | 41 | */ |
AnnaBridge | 178:79309dc6340a | 42 | /** Class FileBase |
AnnaBridge | 178:79309dc6340a | 43 | * |
AnnaBridge | 178:79309dc6340a | 44 | */ |
AnnaBridge | 178:79309dc6340a | 45 | |
AnnaBridge | 168:9672193075cf | 46 | class FileBase : private NonCopyable<FileBase> { |
AnnaBridge | 167:e84263d55307 | 47 | public: |
AnnaBridge | 167:e84263d55307 | 48 | FileBase(const char *name, PathType t); |
AnnaBridge | 167:e84263d55307 | 49 | virtual ~FileBase(); |
AnnaBridge | 167:e84263d55307 | 50 | |
AnnaBridge | 167:e84263d55307 | 51 | const char* getName(void); |
AnnaBridge | 167:e84263d55307 | 52 | PathType getPathType(void); |
AnnaBridge | 167:e84263d55307 | 53 | |
AnnaBridge | 167:e84263d55307 | 54 | static FileBase *lookup(const char *name, unsigned int len); |
AnnaBridge | 167:e84263d55307 | 55 | |
AnnaBridge | 167:e84263d55307 | 56 | static FileBase *get(int n); |
AnnaBridge | 167:e84263d55307 | 57 | |
AnnaBridge | 167:e84263d55307 | 58 | /* disallow copy constructor and assignment operators */ |
AnnaBridge | 167:e84263d55307 | 59 | private: |
AnnaBridge | 167:e84263d55307 | 60 | static FileBase *_head; |
AnnaBridge | 167:e84263d55307 | 61 | static SingletonPtr<PlatformMutex> _mutex; |
AnnaBridge | 167:e84263d55307 | 62 | |
AnnaBridge | 167:e84263d55307 | 63 | FileBase *_next; |
AnnaBridge | 167:e84263d55307 | 64 | const char * const _name; |
AnnaBridge | 167:e84263d55307 | 65 | const PathType _path_type; |
AnnaBridge | 167:e84263d55307 | 66 | }; |
AnnaBridge | 167:e84263d55307 | 67 | |
AnnaBridge | 178:79309dc6340a | 68 | /**@}*/ |
AnnaBridge | 178:79309dc6340a | 69 | |
AnnaBridge | 178:79309dc6340a | 70 | /**@}*/ |
AnnaBridge | 178:79309dc6340a | 71 | |
AnnaBridge | 167:e84263d55307 | 72 | } // namespace mbed |
AnnaBridge | 167:e84263d55307 | 73 | |
AnnaBridge | 167:e84263d55307 | 74 | #endif |
AnnaBridge | 167:e84263d55307 | 75 |