mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
FileSystemHandle.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 #ifndef MBED_FILESYSTEMHANDLE_H 00018 #define MBED_FILESYSTEMHANDLE_H 00019 00020 #include "platform/platform.h" 00021 00022 #include "platform/FileBase.h" 00023 #include "platform/FileHandle.h" 00024 #include "platform/DirHandle.h" 00025 #include "platform/NonCopyable.h" 00026 00027 namespace mbed { 00028 /** \addtogroup platform */ 00029 /** @{*/ 00030 /** 00031 * \defgroup platform_FileSystemHandle FileSystemHandle functions 00032 * @{ 00033 */ 00034 00035 00036 /** A filesystem-like object is one that can be used to open file-like 00037 * objects though it by fopen("/name/filename", mode) 00038 * 00039 * Implementations must define at least open (the default definitions 00040 * of the rest of the functions just return error values). 00041 * 00042 * @note Synchronization level: Set by subclass 00043 */ 00044 class FileSystemHandle : private NonCopyable<FileSystemHandle> { 00045 public: 00046 /** FileSystemHandle lifetime 00047 */ 00048 virtual ~FileSystemHandle() {} 00049 00050 /** Open a file on the filesystem 00051 * 00052 * @param file Destination for the handle to a newly created file 00053 * @param filename The name of the file to open 00054 * @param flags The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR, 00055 * bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND 00056 * @return 0 on success, negative error code on failure 00057 */ 00058 virtual int open(FileHandle **file, const char *filename, int flags) = 0; 00059 00060 /** Open a directory on the filesystem 00061 * 00062 * @param dir Destination for the handle to the directory 00063 * @param path Name of the directory to open 00064 * @return 0 on success, negative error code on failure 00065 */ 00066 virtual int open(DirHandle **dir, const char *path); 00067 00068 /** Remove a file from the filesystem. 00069 * 00070 * @param path The name of the file to remove. 00071 * @return 0 on success, negative error code on failure 00072 */ 00073 virtual int remove(const char *path); 00074 00075 /** Rename a file in the filesystem. 00076 * 00077 * @param path The name of the file to rename. 00078 * @param newpath The name to rename it to 00079 * @return 0 on success, negative error code on failure 00080 */ 00081 virtual int rename(const char *path, const char *newpath); 00082 00083 /** Store information about the file in a stat structure 00084 * 00085 * @param path The name of the file to find information about 00086 * @param st The stat buffer to write to 00087 * @return 0 on success, negative error code on failure 00088 */ 00089 virtual int stat(const char *path, struct stat *st); 00090 00091 /** Create a directory in the filesystem. 00092 * 00093 * @param path The name of the directory to create. 00094 * @param mode The permissions with which to create the directory 00095 * @return 0 on success, negative error code on failure 00096 */ 00097 virtual int mkdir(const char *path, mode_t mode); 00098 00099 /** Store information about the mounted filesystem in a statvfs structure 00100 * 00101 * @param path The name of the file to find information about 00102 * @param buf The stat buffer to write to 00103 * @return 0 on success, negative error code on failure 00104 */ 00105 virtual int statvfs(const char *path, struct statvfs *buf); 00106 }; 00107 /**@}*/ 00108 00109 /**@}*/ 00110 00111 } // namespace mbed 00112 00113 #endif
Generated on Tue Jul 12 2022 20:41:14 by 1.7.2