forked
Embed:
(wiki syntax)
Show/hide line numbers
FileSystemHandle.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_FILESYSTEMHANDLE_H 00017 #define MBED_FILESYSTEMHANDLE_H 00018 00019 #include "platform/platform.h" 00020 00021 #include "platform/FileBase.h" 00022 #include "platform/FileHandle.h" 00023 #include "platform/DirHandle.h" 00024 #include "platform/NonCopyable.h" 00025 00026 namespace mbed { 00027 /** \addtogroup drivers */ 00028 /** @{*/ 00029 00030 00031 /** A filesystem-like object is one that can be used to open file-like 00032 * objects though it by fopen("/name/filename", mode) 00033 * 00034 * Implementations must define at least open (the default definitions 00035 * of the rest of the functions just return error values). 00036 * 00037 * @note Synchronization level: Set by subclass 00038 */ 00039 class FileSystemHandle : private NonCopyable<FileSystemHandle> { 00040 public: 00041 /** FileSystemHandle lifetime 00042 */ 00043 virtual ~FileSystemHandle() {} 00044 00045 /** Open a file on the filesystem 00046 * 00047 * @param file Destination for the handle to a newly created file 00048 * @param filename The name of the file to open 00049 * @param flags The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR, 00050 * bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND 00051 * @return 0 on success, negative error code on failure 00052 */ 00053 virtual int open(FileHandle **file, const char *filename, int flags) = 0; 00054 00055 /** Open a directory on the filesystem 00056 * 00057 * @param dir Destination for the handle to the directory 00058 * @param path Name of the directory to open 00059 * @return 0 on success, negative error code on failure 00060 */ 00061 virtual int open(DirHandle **dir, const char *path); 00062 00063 /** Remove a file from the filesystem. 00064 * 00065 * @param path The name of the file to remove. 00066 * @return 0 on success, negative error code on failure 00067 */ 00068 virtual int remove(const char *path); 00069 00070 /** Rename a file in the filesystem. 00071 * 00072 * @param path The name of the file to rename. 00073 * @param newpath The name to rename it to 00074 * @return 0 on success, negative error code on failure 00075 */ 00076 virtual int rename(const char *path, const char *newpath); 00077 00078 /** Store information about the file in a stat structure 00079 * 00080 * @param path The name of the file to find information about 00081 * @param st The stat buffer to write to 00082 * @return 0 on success, negative error code on failure 00083 */ 00084 virtual int stat(const char *path, struct stat *st); 00085 00086 /** Create a directory in the filesystem. 00087 * 00088 * @param path The name of the directory to create. 00089 * @param mode The permissions with which to create the directory 00090 * @return 0 on success, negative error code on failure 00091 */ 00092 virtual int mkdir(const char *path, mode_t mode); 00093 }; 00094 00095 00096 } // namespace mbed 00097 00098 #endif 00099 00100 /** @}*/
Generated on Tue Jul 12 2022 16:02:32 by 1.7.2