mbed library for NZ32-SC151

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 
00045 namespace mbed {
00046 
00047 typedef enum {
00048     FilePathType,
00049     FileSystemPathType
00050 } PathType;
00051 
00052 class FileBase {
00053 public:
00054     FileBase(const char *name, PathType t);
00055 
00056     virtual ~FileBase();
00057 
00058     const char* getName(void);
00059     PathType    getPathType(void);
00060 
00061     static FileBase *lookup(const char *name, unsigned int len);
00062 
00063     static FileBase *get(int n);
00064 
00065 protected:
00066     static FileBase *_head;
00067 
00068     FileBase   *_next;
00069     const char *_name;
00070     PathType    _path_type;
00071 
00072     /* disallow copy constructor and assignment operators */
00073 private:
00074     FileBase(const FileBase&);
00075     FileBase & operator = (const FileBase&);
00076 };
00077 
00078 } // namespace mbed
00079 
00080 #endif