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