TUKS MCU Introductory course / TUKS-COURSE-TIMER
Committer:
elmot
Date:
Fri Feb 24 21:13:56 2017 +0000
Revision:
1:d0dfbce63a89
Ready-to-copy

Who changed what in which revision?

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