Life is random and unfair!
Fork of mbed-dev by
Embed:
(wiki syntax)
Show/hide line numbers
FileSystemLike.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef MBED_FILESYSTEMLIKE_H 00017 #define MBED_FILESYSTEMLIKE_H 00018 00019 #include "platform/platform.h" 00020 00021 #include "drivers/FileBase.h" 00022 #include "drivers/FileHandle.h" 00023 #include "drivers/DirHandle.h" 00024 00025 namespace mbed { 00026 /** \addtogroup drivers */ 00027 /** @{*/ 00028 00029 /** A filesystem-like object is one that can be used to open files 00030 * though it by fopen("/name/filename", mode) 00031 * 00032 * Implementations must define at least open (the default definitions 00033 * of the rest of the functions just return error values). 00034 * 00035 * @Note Synchronization level: Set by subclass 00036 */ 00037 class FileSystemLike : public FileBase { 00038 00039 public: 00040 /** FileSystemLike constructor 00041 * 00042 * @param name The name to use for the filesystem. 00043 */ 00044 MBED_DEPRECATED_SINCE("mbed-os-5.4", 00045 "The mbed 2 filesystem classes have been superseeded by the FileSystem api, " 00046 "Replaced by FileSystem") 00047 FileSystemLike(const char *name); 00048 00049 virtual ~FileSystemLike(); 00050 00051 MBED_DEPRECATED_SINCE("mbed-os-5.4", 00052 "The mbed 2 filesystem classes have been superseeded by the FileSystem api, " 00053 "Replaced by FileSystem") 00054 static DirHandle *opendir(); 00055 friend class BaseDirHandle; 00056 00057 /** Opens a file from the filesystem 00058 * 00059 * @param filename The name of the file to open. 00060 * @param flags One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with 00061 * zero or more of O_CREAT, O_TRUNC, or O_APPEND. 00062 * 00063 * @returns 00064 * A pointer to a FileHandle object representing the 00065 * file on success, or NULL on failure. 00066 */ 00067 virtual FileHandle *open(const char *filename, int flags) = 0; 00068 00069 /** Remove a file from the filesystem. 00070 * 00071 * @param filename the name of the file to remove. 00072 * @param returns 0 on success, -1 on failure. 00073 */ 00074 virtual int remove(const char *filename) { (void) filename; return -1; }; 00075 00076 /** Rename a file in the filesystem. 00077 * 00078 * @param oldname the name of the file to rename. 00079 * @param newname the name to rename it to. 00080 * 00081 * @returns 00082 * 0 on success, 00083 * -1 on failure. 00084 */ 00085 virtual int rename(const char *oldname, const char *newname) { (void) oldname, (void) newname; return -1; }; 00086 00087 /** Opens a directory in the filesystem and returns a DirHandle 00088 * representing the directory stream. 00089 * 00090 * @param name The name of the directory to open. 00091 * 00092 * @returns 00093 * A DirHandle representing the directory stream, or 00094 * NULL on failure. 00095 */ 00096 virtual DirHandle *opendir(const char *name) { (void) name; return NULL; }; 00097 00098 /** Creates a directory in the filesystem. 00099 * 00100 * @param name The name of the directory to create. 00101 * @param mode The permissions to create the directory with. 00102 * 00103 * @returns 00104 * 0 on success, 00105 * -1 on failure. 00106 */ 00107 virtual int mkdir(const char *name, mode_t mode) { (void) name, (void) mode; return -1; } 00108 00109 /** Store information about file in stat structure 00110 * 00111 * @param name The name of the file to find information about 00112 * @param st The stat buffer to write to 00113 * @returns 00114 * 0 on success or un-needed, 00115 * -1 on error 00116 */ 00117 virtual int stat(const char *name, struct stat *st) { return -1; }; 00118 }; 00119 00120 } // namespace mbed 00121 00122 #endif 00123 00124 /** @}*/
Generated on Tue Jul 12 2022 19:28:24 by 1.7.2