This is a repository for all my programs or modified programs.

Committer:
mturner5
Date:
Sun Sep 11 23:48:09 2016 +0000
Revision:
0:72480818e4a9
Made delays for the LEDS and button presses

Who changed what in which revision?

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