mbed library for NZ32-SC151

Committer:
modtronix-com
Date:
Fri Aug 19 15:46:42 2016 +1000
Revision:
17:639ed60ce759
Parent:
1:71204b8406f2
Added tag v1.1 for changeset 076cbe3e55be

Who changed what in which revision?

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