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