Official Sheffield ARMBand micro:bit program

Committer:
MrBedfordVan
Date:
Mon Oct 17 12:41:20 2016 +0000
Revision:
0:b9164b348919
Official Sheffield ARMBand Micro:bit program

Who changed what in which revision?

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