mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
<>
Date:
Tue Dec 20 17:27:56 2016 +0000
Revision:
153:fa9ff456f731
Parent:
149:156823d33999
Child:
160:d5399cc887bb
This updates the lib to the mbed lib v132

Who changed what in which revision?

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