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