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