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