Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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.h" 00020 00021 #include "FileBase.h" 00022 #include "FileHandle.h" 00023 #include "DirHandle.h" 00024 00025 namespace mbed { 00026 00027 /** A filesystem-like object is one that can be used to open files 00028 * though it by fopen("/name/filename", mode) 00029 * 00030 * Implementations must define at least open (the default definitions 00031 * of the rest of the functions just return error values). 00032 * 00033 * @Note Synchronization level: Set by subclass 00034 */ 00035 class FileSystemLike : public FileBase { 00036 00037 public: 00038 /** FileSystemLike constructor 00039 * 00040 * @param name The name to use for the filesystem. 00041 */ 00042 FileSystemLike(const char *name); 00043 00044 virtual ~FileSystemLike(); 00045 00046 static DirHandle *opendir(); 00047 friend class BaseDirHandle; 00048 00049 /** Opens a file from the filesystem 00050 * 00051 * @param filename The name of the file to open. 00052 * @param flags One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with 00053 * zero or more of O_CREAT, O_TRUNC, or O_APPEND. 00054 * 00055 * @returns 00056 * A pointer to a FileHandle object representing the 00057 * file on success, or NULL on failure. 00058 */ 00059 virtual FileHandle *open(const char *filename, int flags) = 0; 00060 00061 /** Remove a file from the filesystem. 00062 * 00063 * @param filename the name of the file to remove. 00064 * @param returns 0 on success, -1 on failure. 00065 */ 00066 virtual int remove(const char *filename) { (void) filename; return -1; }; 00067 00068 /** Rename a file in the filesystem. 00069 * 00070 * @param oldname the name of the file to rename. 00071 * @param newname the name to rename it to. 00072 * 00073 * @returns 00074 * 0 on success, 00075 * -1 on failure. 00076 */ 00077 virtual int rename(const char *oldname, const char *newname) { (void) oldname, (void) newname; return -1; }; 00078 00079 /** Opens a directory in the filesystem and returns a DirHandle 00080 * representing the directory stream. 00081 * 00082 * @param name The name of the directory to open. 00083 * 00084 * @returns 00085 * A DirHandle representing the directory stream, or 00086 * NULL on failure. 00087 */ 00088 virtual DirHandle *opendir(const char *name) { (void) name; return NULL; }; 00089 00090 /** Creates a directory in the filesystem. 00091 * 00092 * @param name The name of the directory to create. 00093 * @param mode The permissions to create the directory with. 00094 * 00095 * @returns 00096 * 0 on success, 00097 * -1 on failure. 00098 */ 00099 virtual int mkdir(const char *name, mode_t mode) { (void) name, (void) mode; return -1; } 00100 00101 // TODO other filesystem functions (mkdir, rm, rn, ls etc) 00102 }; 00103 00104 } // namespace mbed 00105 00106 #endif
Generated on Tue Jul 12 2022 22:19:20 by
