dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
cyberjoey
Date:
Sat Oct 22 01:31:58 2016 +0000
Revision:
9:6bb35cef007d
Parent:
1:55a6170b404f
WORKING

Who changed what in which revision?

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