Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:54:50 2016 +0000
Revision:
1:d96dbedaebdb
Parent:
0:6c56fb4bc5f0
Removed extra directories for other platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:6c56fb4bc5f0 1 /* mbed Microcontroller Library
nexpaq 0:6c56fb4bc5f0 2 * Copyright (c) 2006-2013 ARM Limited
nexpaq 0:6c56fb4bc5f0 3 *
nexpaq 0:6c56fb4bc5f0 4 * Licensed under the Apache License, Version 2.0 (the "License");
nexpaq 0:6c56fb4bc5f0 5 * you may not use this file except in compliance with the License.
nexpaq 0:6c56fb4bc5f0 6 * You may obtain a copy of the License at
nexpaq 0:6c56fb4bc5f0 7 *
nexpaq 0:6c56fb4bc5f0 8 * http://www.apache.org/licenses/LICENSE-2.0
nexpaq 0:6c56fb4bc5f0 9 *
nexpaq 0:6c56fb4bc5f0 10 * Unless required by applicable law or agreed to in writing, software
nexpaq 0:6c56fb4bc5f0 11 * distributed under the License is distributed on an "AS IS" BASIS,
nexpaq 0:6c56fb4bc5f0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nexpaq 0:6c56fb4bc5f0 13 * See the License for the specific language governing permissions and
nexpaq 0:6c56fb4bc5f0 14 * limitations under the License.
nexpaq 0:6c56fb4bc5f0 15 */
nexpaq 0:6c56fb4bc5f0 16 #ifndef MBED_FILESYSTEMLIKE_H
nexpaq 0:6c56fb4bc5f0 17 #define MBED_FILESYSTEMLIKE_H
nexpaq 0:6c56fb4bc5f0 18
nexpaq 0:6c56fb4bc5f0 19 #include "platform.h"
nexpaq 0:6c56fb4bc5f0 20
nexpaq 0:6c56fb4bc5f0 21 #include "FileBase.h"
nexpaq 0:6c56fb4bc5f0 22 #include "FileHandle.h"
nexpaq 0:6c56fb4bc5f0 23 #include "DirHandle.h"
nexpaq 0:6c56fb4bc5f0 24
nexpaq 0:6c56fb4bc5f0 25 namespace mbed {
nexpaq 0:6c56fb4bc5f0 26
nexpaq 0:6c56fb4bc5f0 27 /** A filesystem-like object is one that can be used to open files
nexpaq 0:6c56fb4bc5f0 28 * though it by fopen("/name/filename", mode)
nexpaq 0:6c56fb4bc5f0 29 *
nexpaq 0:6c56fb4bc5f0 30 * Implementations must define at least open (the default definitions
nexpaq 0:6c56fb4bc5f0 31 * of the rest of the functions just return error values).
nexpaq 0:6c56fb4bc5f0 32 *
nexpaq 0:6c56fb4bc5f0 33 * @Note Synchronization level: Set by subclass
nexpaq 0:6c56fb4bc5f0 34 */
nexpaq 0:6c56fb4bc5f0 35 class FileSystemLike : public FileBase {
nexpaq 0:6c56fb4bc5f0 36
nexpaq 0:6c56fb4bc5f0 37 public:
nexpaq 0:6c56fb4bc5f0 38 /** FileSystemLike constructor
nexpaq 0:6c56fb4bc5f0 39 *
nexpaq 0:6c56fb4bc5f0 40 * @param name The name to use for the filesystem.
nexpaq 0:6c56fb4bc5f0 41 */
nexpaq 0:6c56fb4bc5f0 42 FileSystemLike(const char *name);
nexpaq 0:6c56fb4bc5f0 43
nexpaq 0:6c56fb4bc5f0 44 virtual ~FileSystemLike();
nexpaq 0:6c56fb4bc5f0 45
nexpaq 0:6c56fb4bc5f0 46 static DirHandle *opendir();
nexpaq 0:6c56fb4bc5f0 47 friend class BaseDirHandle;
nexpaq 0:6c56fb4bc5f0 48
nexpaq 0:6c56fb4bc5f0 49 /** Opens a file from the filesystem
nexpaq 0:6c56fb4bc5f0 50 *
nexpaq 0:6c56fb4bc5f0 51 * @param filename The name of the file to open.
nexpaq 0:6c56fb4bc5f0 52 * @param flags One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with
nexpaq 0:6c56fb4bc5f0 53 * zero or more of O_CREAT, O_TRUNC, or O_APPEND.
nexpaq 0:6c56fb4bc5f0 54 *
nexpaq 0:6c56fb4bc5f0 55 * @returns
nexpaq 0:6c56fb4bc5f0 56 * A pointer to a FileHandle object representing the
nexpaq 0:6c56fb4bc5f0 57 * file on success, or NULL on failure.
nexpaq 0:6c56fb4bc5f0 58 */
nexpaq 0:6c56fb4bc5f0 59 virtual FileHandle *open(const char *filename, int flags) = 0;
nexpaq 0:6c56fb4bc5f0 60
nexpaq 0:6c56fb4bc5f0 61 /** Remove a file from the filesystem.
nexpaq 0:6c56fb4bc5f0 62 *
nexpaq 0:6c56fb4bc5f0 63 * @param filename the name of the file to remove.
nexpaq 0:6c56fb4bc5f0 64 * @param returns 0 on success, -1 on failure.
nexpaq 0:6c56fb4bc5f0 65 */
nexpaq 0:6c56fb4bc5f0 66 virtual int remove(const char *filename) { (void) filename; return -1; };
nexpaq 0:6c56fb4bc5f0 67
nexpaq 0:6c56fb4bc5f0 68 /** Rename a file in the filesystem.
nexpaq 0:6c56fb4bc5f0 69 *
nexpaq 0:6c56fb4bc5f0 70 * @param oldname the name of the file to rename.
nexpaq 0:6c56fb4bc5f0 71 * @param newname the name to rename it to.
nexpaq 0:6c56fb4bc5f0 72 *
nexpaq 0:6c56fb4bc5f0 73 * @returns
nexpaq 0:6c56fb4bc5f0 74 * 0 on success,
nexpaq 0:6c56fb4bc5f0 75 * -1 on failure.
nexpaq 0:6c56fb4bc5f0 76 */
nexpaq 0:6c56fb4bc5f0 77 virtual int rename(const char *oldname, const char *newname) { (void) oldname, (void) newname; return -1; };
nexpaq 0:6c56fb4bc5f0 78
nexpaq 0:6c56fb4bc5f0 79 /** Opens a directory in the filesystem and returns a DirHandle
nexpaq 0:6c56fb4bc5f0 80 * representing the directory stream.
nexpaq 0:6c56fb4bc5f0 81 *
nexpaq 0:6c56fb4bc5f0 82 * @param name The name of the directory to open.
nexpaq 0:6c56fb4bc5f0 83 *
nexpaq 0:6c56fb4bc5f0 84 * @returns
nexpaq 0:6c56fb4bc5f0 85 * A DirHandle representing the directory stream, or
nexpaq 0:6c56fb4bc5f0 86 * NULL on failure.
nexpaq 0:6c56fb4bc5f0 87 */
nexpaq 0:6c56fb4bc5f0 88 virtual DirHandle *opendir(const char *name) { (void) name; return NULL; };
nexpaq 0:6c56fb4bc5f0 89
nexpaq 0:6c56fb4bc5f0 90 /** Creates a directory in the filesystem.
nexpaq 0:6c56fb4bc5f0 91 *
nexpaq 0:6c56fb4bc5f0 92 * @param name The name of the directory to create.
nexpaq 0:6c56fb4bc5f0 93 * @param mode The permissions to create the directory with.
nexpaq 0:6c56fb4bc5f0 94 *
nexpaq 0:6c56fb4bc5f0 95 * @returns
nexpaq 0:6c56fb4bc5f0 96 * 0 on success,
nexpaq 0:6c56fb4bc5f0 97 * -1 on failure.
nexpaq 0:6c56fb4bc5f0 98 */
nexpaq 0:6c56fb4bc5f0 99 virtual int mkdir(const char *name, mode_t mode) { (void) name, (void) mode; return -1; }
nexpaq 0:6c56fb4bc5f0 100
nexpaq 0:6c56fb4bc5f0 101 // TODO other filesystem functions (mkdir, rm, rn, ls etc)
nexpaq 0:6c56fb4bc5f0 102 };
nexpaq 0:6c56fb4bc5f0 103
nexpaq 0:6c56fb4bc5f0 104 } // namespace mbed
nexpaq 0:6c56fb4bc5f0 105
nexpaq 0:6c56fb4bc5f0 106 #endif