This fork captures the mbed lib v125 for ease of integration into older projects.

Fork of mbed-dev by mbed official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FileBase.h Source File

FileBase.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef MBED_FILEBASE_H
00017 #define MBED_FILEBASE_H
00018 
00019 typedef int FILEHANDLE;
00020 
00021 #include <stdio.h>
00022 
00023 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
00024 #    define O_RDONLY 0
00025 #    define O_WRONLY 1
00026 #    define O_RDWR   2
00027 #    define O_CREAT  0x0200
00028 #    define O_TRUNC  0x0400
00029 #    define O_APPEND 0x0008
00030 
00031 #    define NAME_MAX 255
00032 
00033 typedef int mode_t;
00034 typedef int ssize_t;
00035 typedef long off_t;
00036 
00037 #else
00038 #    include <sys/fcntl.h>
00039 #    include <sys/types.h>
00040 #    include <sys/syslimits.h>
00041 #endif
00042 
00043 #include "platform.h"
00044 #include "SingletonPtr.h"
00045 #include "PlatformMutex.h"
00046 
00047 namespace mbed {
00048 
00049 typedef enum {
00050     FilePathType,
00051     FileSystemPathType
00052 } PathType;
00053 
00054 class FileBase {
00055 public:
00056     FileBase(const char *name, PathType t);
00057 
00058     virtual ~FileBase();
00059 
00060     const char* getName(void);
00061     PathType    getPathType(void);
00062 
00063     static FileBase *lookup(const char *name, unsigned int len);
00064 
00065     static FileBase *get(int n);
00066 
00067     /* disallow copy constructor and assignment operators */
00068 private:
00069     static FileBase *_head;
00070     static SingletonPtr<PlatformMutex>  _mutex;
00071 
00072     FileBase   *_next;
00073     const char * const _name;
00074     const PathType _path_type;
00075     FileBase(const FileBase&);
00076     FileBase & operator = (const FileBase&);
00077 };
00078 
00079 } // namespace mbed
00080 
00081 #endif