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.
Fork of mbed-src by
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 class FileSystemLike : public FileBase { 00034 00035 public: 00036 /** FileSystemLike constructor 00037 * 00038 * @param name The name to use for the filesystem. 00039 */ 00040 FileSystemLike(const char *name); 00041 00042 virtual ~FileSystemLike(); 00043 00044 static DirHandle *opendir(); 00045 friend class BaseDirHandle; 00046 00047 /** Opens a file from the filesystem 00048 * 00049 * @param filename The name of the file to open. 00050 * @param flags One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with 00051 * zero or more of O_CREAT, O_TRUNC, or O_APPEND. 00052 * 00053 * @returns 00054 * A pointer to a FileHandle object representing the 00055 * file on success, or NULL on failure. 00056 */ 00057 virtual FileHandle *open(const char *filename, int flags) = 0; 00058 00059 /** Remove a file from the filesystem. 00060 * 00061 * @param filename the name of the file to remove. 00062 * @param returns 0 on success, -1 on failure. 00063 */ 00064 virtual int remove(const char *filename) { return -1; }; 00065 00066 /** Rename a file in the filesystem. 00067 * 00068 * @param oldname the name of the file to rename. 00069 * @param newname the name to rename it to. 00070 * 00071 * @returns 00072 * 0 on success, 00073 * -1 on failure. 00074 */ 00075 virtual int rename(const char *oldname, const char *newname) { return -1; }; 00076 00077 /** Opens a directory in the filesystem and returns a DirHandle 00078 * representing the directory stream. 00079 * 00080 * @param name The name of the directory to open. 00081 * 00082 * @returns 00083 * A DirHandle representing the directory stream, or 00084 * NULL on failure. 00085 */ 00086 virtual DirHandle *opendir(const char *name) { return NULL; }; 00087 00088 /** Creates a directory in the filesystem. 00089 * 00090 * @param name The name of the directory to create. 00091 * @param mode The permissions to create the directory with. 00092 * 00093 * @returns 00094 * 0 on success, 00095 * -1 on failure. 00096 */ 00097 virtual int mkdir(const char *name, mode_t mode) { return -1; } 00098 00099 // TODO other filesystem functions (mkdir, rm, rn, ls etc) 00100 }; 00101 00102 } // namespace mbed 00103 00104 #endif
Generated on Tue Jul 12 2022 21:21:33 by
