CDY version that shares functionality with Counter
Dependencies: SDFileSystem_HelloWorld mbed FATFileSystem
mbed/drivers/FileBase.h@0:aa13e1c335cd, 2018-11-04 (annotated)
- Committer:
- Charles David Young
- Date:
- Sun Nov 04 18:44:51 2018 -0700
- Revision:
- 0:aa13e1c335cd
create new repo for show2me
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Charles David Young |
0:aa13e1c335cd | 1 | /* mbed Microcontroller Library |
Charles David Young |
0:aa13e1c335cd | 2 | * Copyright (c) 2006-2013 ARM Limited |
Charles David Young |
0:aa13e1c335cd | 3 | * |
Charles David Young |
0:aa13e1c335cd | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Charles David Young |
0:aa13e1c335cd | 5 | * you may not use this file except in compliance with the License. |
Charles David Young |
0:aa13e1c335cd | 6 | * You may obtain a copy of the License at |
Charles David Young |
0:aa13e1c335cd | 7 | * |
Charles David Young |
0:aa13e1c335cd | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Charles David Young |
0:aa13e1c335cd | 9 | * |
Charles David Young |
0:aa13e1c335cd | 10 | * Unless required by applicable law or agreed to in writing, software |
Charles David Young |
0:aa13e1c335cd | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Charles David Young |
0:aa13e1c335cd | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Charles David Young |
0:aa13e1c335cd | 13 | * See the License for the specific language governing permissions and |
Charles David Young |
0:aa13e1c335cd | 14 | * limitations under the License. |
Charles David Young |
0:aa13e1c335cd | 15 | */ |
Charles David Young |
0:aa13e1c335cd | 16 | #ifndef MBED_FILEBASE_H |
Charles David Young |
0:aa13e1c335cd | 17 | #define MBED_FILEBASE_H |
Charles David Young |
0:aa13e1c335cd | 18 | |
Charles David Young |
0:aa13e1c335cd | 19 | typedef int FILEHANDLE; |
Charles David Young |
0:aa13e1c335cd | 20 | |
Charles David Young |
0:aa13e1c335cd | 21 | #include <cstdio> |
Charles David Young |
0:aa13e1c335cd | 22 | #include <cstring> |
Charles David Young |
0:aa13e1c335cd | 23 | |
Charles David Young |
0:aa13e1c335cd | 24 | #if defined(__ARMCC_VERSION) || defined(__ICCARM__) |
Charles David Young |
0:aa13e1c335cd | 25 | # define O_RDONLY 0 |
Charles David Young |
0:aa13e1c335cd | 26 | # define O_WRONLY 1 |
Charles David Young |
0:aa13e1c335cd | 27 | # define O_RDWR 2 |
Charles David Young |
0:aa13e1c335cd | 28 | # define O_CREAT 0x0200 |
Charles David Young |
0:aa13e1c335cd | 29 | # define O_TRUNC 0x0400 |
Charles David Young |
0:aa13e1c335cd | 30 | # define O_APPEND 0x0008 |
Charles David Young |
0:aa13e1c335cd | 31 | |
Charles David Young |
0:aa13e1c335cd | 32 | # define NAME_MAX 255 |
Charles David Young |
0:aa13e1c335cd | 33 | |
Charles David Young |
0:aa13e1c335cd | 34 | typedef int mode_t; |
Charles David Young |
0:aa13e1c335cd | 35 | typedef int ssize_t; |
Charles David Young |
0:aa13e1c335cd | 36 | typedef long off_t; |
Charles David Young |
0:aa13e1c335cd | 37 | |
Charles David Young |
0:aa13e1c335cd | 38 | #else |
Charles David Young |
0:aa13e1c335cd | 39 | # include <sys/fcntl.h> |
Charles David Young |
0:aa13e1c335cd | 40 | # include <sys/types.h> |
Charles David Young |
0:aa13e1c335cd | 41 | # include <sys/syslimits.h> |
Charles David Young |
0:aa13e1c335cd | 42 | #endif |
Charles David Young |
0:aa13e1c335cd | 43 | |
Charles David Young |
0:aa13e1c335cd | 44 | #include "platform/platform.h" |
Charles David Young |
0:aa13e1c335cd | 45 | #include "platform/SingletonPtr.h" |
Charles David Young |
0:aa13e1c335cd | 46 | #include "platform/PlatformMutex.h" |
Charles David Young |
0:aa13e1c335cd | 47 | |
Charles David Young |
0:aa13e1c335cd | 48 | namespace mbed { |
Charles David Young |
0:aa13e1c335cd | 49 | /** \addtogroup drivers */ |
Charles David Young |
0:aa13e1c335cd | 50 | /** @{*/ |
Charles David Young |
0:aa13e1c335cd | 51 | |
Charles David Young |
0:aa13e1c335cd | 52 | typedef enum { |
Charles David Young |
0:aa13e1c335cd | 53 | FilePathType, |
Charles David Young |
0:aa13e1c335cd | 54 | FileSystemPathType |
Charles David Young |
0:aa13e1c335cd | 55 | } PathType; |
Charles David Young |
0:aa13e1c335cd | 56 | |
Charles David Young |
0:aa13e1c335cd | 57 | class FileBase { |
Charles David Young |
0:aa13e1c335cd | 58 | public: |
Charles David Young |
0:aa13e1c335cd | 59 | FileBase(const char *name, PathType t); |
Charles David Young |
0:aa13e1c335cd | 60 | |
Charles David Young |
0:aa13e1c335cd | 61 | virtual ~FileBase(); |
Charles David Young |
0:aa13e1c335cd | 62 | |
Charles David Young |
0:aa13e1c335cd | 63 | const char* getName(void); |
Charles David Young |
0:aa13e1c335cd | 64 | PathType getPathType(void); |
Charles David Young |
0:aa13e1c335cd | 65 | |
Charles David Young |
0:aa13e1c335cd | 66 | static FileBase *lookup(const char *name, unsigned int len); |
Charles David Young |
0:aa13e1c335cd | 67 | |
Charles David Young |
0:aa13e1c335cd | 68 | static FileBase *get(int n); |
Charles David Young |
0:aa13e1c335cd | 69 | |
Charles David Young |
0:aa13e1c335cd | 70 | /* disallow copy constructor and assignment operators */ |
Charles David Young |
0:aa13e1c335cd | 71 | private: |
Charles David Young |
0:aa13e1c335cd | 72 | static FileBase *_head; |
Charles David Young |
0:aa13e1c335cd | 73 | static SingletonPtr<PlatformMutex> _mutex; |
Charles David Young |
0:aa13e1c335cd | 74 | |
Charles David Young |
0:aa13e1c335cd | 75 | FileBase *_next; |
Charles David Young |
0:aa13e1c335cd | 76 | const char * const _name; |
Charles David Young |
0:aa13e1c335cd | 77 | const PathType _path_type; |
Charles David Young |
0:aa13e1c335cd | 78 | FileBase(const FileBase&); |
Charles David Young |
0:aa13e1c335cd | 79 | FileBase & operator = (const FileBase&); |
Charles David Young |
0:aa13e1c335cd | 80 | }; |
Charles David Young |
0:aa13e1c335cd | 81 | |
Charles David Young |
0:aa13e1c335cd | 82 | } // namespace mbed |
Charles David Young |
0:aa13e1c335cd | 83 | |
Charles David Young |
0:aa13e1c335cd | 84 | #endif |
Charles David Young |
0:aa13e1c335cd | 85 | |
Charles David Young |
0:aa13e1c335cd | 86 | /** @}*/ |