mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
187:0387e8f68319
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 167:e84263d55307 1 /* mbed Microcontroller Library
AnnaBridge 167:e84263d55307 2 * Copyright (c) 2006-2013 ARM Limited
AnnaBridge 189:f392fc9709a3 3 * SPDX-License-Identifier: Apache-2.0
AnnaBridge 167:e84263d55307 4 *
AnnaBridge 167:e84263d55307 5 * Licensed under the Apache License, Version 2.0 (the "License");
AnnaBridge 167:e84263d55307 6 * you may not use this file except in compliance with the License.
AnnaBridge 167:e84263d55307 7 * You may obtain a copy of the License at
AnnaBridge 167:e84263d55307 8 *
AnnaBridge 167:e84263d55307 9 * http://www.apache.org/licenses/LICENSE-2.0
AnnaBridge 167:e84263d55307 10 *
AnnaBridge 167:e84263d55307 11 * Unless required by applicable law or agreed to in writing, software
AnnaBridge 167:e84263d55307 12 * distributed under the License is distributed on an "AS IS" BASIS,
AnnaBridge 167:e84263d55307 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AnnaBridge 167:e84263d55307 14 * See the License for the specific language governing permissions and
AnnaBridge 167:e84263d55307 15 * limitations under the License.
AnnaBridge 167:e84263d55307 16 */
AnnaBridge 167:e84263d55307 17 #ifndef MBED_FILESYSTEMHANDLE_H
AnnaBridge 167:e84263d55307 18 #define MBED_FILESYSTEMHANDLE_H
AnnaBridge 167:e84263d55307 19
AnnaBridge 167:e84263d55307 20 #include "platform/platform.h"
AnnaBridge 167:e84263d55307 21
AnnaBridge 167:e84263d55307 22 #include "platform/FileBase.h"
AnnaBridge 167:e84263d55307 23 #include "platform/FileHandle.h"
AnnaBridge 167:e84263d55307 24 #include "platform/DirHandle.h"
AnnaBridge 168:9672193075cf 25 #include "platform/NonCopyable.h"
AnnaBridge 167:e84263d55307 26
AnnaBridge 167:e84263d55307 27 namespace mbed {
AnnaBridge 177:d650f5d4c87a 28 /** \addtogroup platform */
AnnaBridge 167:e84263d55307 29 /** @{*/
AnnaBridge 178:79309dc6340a 30 /**
AnnaBridge 178:79309dc6340a 31 * \defgroup platform_FileSystemHandle FileSystemHandle functions
AnnaBridge 178:79309dc6340a 32 * @{
AnnaBridge 178:79309dc6340a 33 */
AnnaBridge 167:e84263d55307 34
AnnaBridge 167:e84263d55307 35
AnnaBridge 167:e84263d55307 36 /** A filesystem-like object is one that can be used to open file-like
AnnaBridge 167:e84263d55307 37 * objects though it by fopen("/name/filename", mode)
AnnaBridge 167:e84263d55307 38 *
AnnaBridge 167:e84263d55307 39 * Implementations must define at least open (the default definitions
AnnaBridge 167:e84263d55307 40 * of the rest of the functions just return error values).
AnnaBridge 167:e84263d55307 41 *
AnnaBridge 167:e84263d55307 42 * @note Synchronization level: Set by subclass
AnnaBridge 167:e84263d55307 43 */
AnnaBridge 168:9672193075cf 44 class FileSystemHandle : private NonCopyable<FileSystemHandle> {
AnnaBridge 167:e84263d55307 45 public:
AnnaBridge 167:e84263d55307 46 /** FileSystemHandle lifetime
AnnaBridge 167:e84263d55307 47 */
AnnaBridge 167:e84263d55307 48 virtual ~FileSystemHandle() {}
AnnaBridge 167:e84263d55307 49
AnnaBridge 167:e84263d55307 50 /** Open a file on the filesystem
AnnaBridge 167:e84263d55307 51 *
AnnaBridge 167:e84263d55307 52 * @param file Destination for the handle to a newly created file
AnnaBridge 167:e84263d55307 53 * @param filename The name of the file to open
AnnaBridge 167:e84263d55307 54 * @param flags The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR,
AnnaBridge 167:e84263d55307 55 * bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND
AnnaBridge 167:e84263d55307 56 * @return 0 on success, negative error code on failure
AnnaBridge 167:e84263d55307 57 */
AnnaBridge 167:e84263d55307 58 virtual int open(FileHandle **file, const char *filename, int flags) = 0;
AnnaBridge 167:e84263d55307 59
AnnaBridge 167:e84263d55307 60 /** Open a directory on the filesystem
AnnaBridge 167:e84263d55307 61 *
AnnaBridge 167:e84263d55307 62 * @param dir Destination for the handle to the directory
AnnaBridge 167:e84263d55307 63 * @param path Name of the directory to open
AnnaBridge 167:e84263d55307 64 * @return 0 on success, negative error code on failure
AnnaBridge 167:e84263d55307 65 */
AnnaBridge 167:e84263d55307 66 virtual int open(DirHandle **dir, const char *path);
AnnaBridge 167:e84263d55307 67
AnnaBridge 167:e84263d55307 68 /** Remove a file from the filesystem.
AnnaBridge 167:e84263d55307 69 *
AnnaBridge 167:e84263d55307 70 * @param path The name of the file to remove.
AnnaBridge 167:e84263d55307 71 * @return 0 on success, negative error code on failure
AnnaBridge 167:e84263d55307 72 */
AnnaBridge 167:e84263d55307 73 virtual int remove(const char *path);
AnnaBridge 167:e84263d55307 74
AnnaBridge 167:e84263d55307 75 /** Rename a file in the filesystem.
AnnaBridge 167:e84263d55307 76 *
AnnaBridge 167:e84263d55307 77 * @param path The name of the file to rename.
AnnaBridge 167:e84263d55307 78 * @param newpath The name to rename it to
AnnaBridge 167:e84263d55307 79 * @return 0 on success, negative error code on failure
AnnaBridge 167:e84263d55307 80 */
AnnaBridge 167:e84263d55307 81 virtual int rename(const char *path, const char *newpath);
AnnaBridge 167:e84263d55307 82
AnnaBridge 167:e84263d55307 83 /** Store information about the file in a stat structure
AnnaBridge 167:e84263d55307 84 *
AnnaBridge 167:e84263d55307 85 * @param path The name of the file to find information about
AnnaBridge 167:e84263d55307 86 * @param st The stat buffer to write to
AnnaBridge 167:e84263d55307 87 * @return 0 on success, negative error code on failure
AnnaBridge 167:e84263d55307 88 */
AnnaBridge 167:e84263d55307 89 virtual int stat(const char *path, struct stat *st);
AnnaBridge 167:e84263d55307 90
AnnaBridge 167:e84263d55307 91 /** Create a directory in the filesystem.
AnnaBridge 167:e84263d55307 92 *
AnnaBridge 167:e84263d55307 93 * @param path The name of the directory to create.
AnnaBridge 167:e84263d55307 94 * @param mode The permissions with which to create the directory
AnnaBridge 167:e84263d55307 95 * @return 0 on success, negative error code on failure
AnnaBridge 167:e84263d55307 96 */
AnnaBridge 167:e84263d55307 97 virtual int mkdir(const char *path, mode_t mode);
AnnaBridge 184:08ed48f1de7f 98
AnnaBridge 184:08ed48f1de7f 99 /** Store information about the mounted filesystem in a statvfs structure
AnnaBridge 184:08ed48f1de7f 100 *
AnnaBridge 184:08ed48f1de7f 101 * @param path The name of the file to find information about
AnnaBridge 184:08ed48f1de7f 102 * @param buf The stat buffer to write to
AnnaBridge 184:08ed48f1de7f 103 * @return 0 on success, negative error code on failure
AnnaBridge 184:08ed48f1de7f 104 */
AnnaBridge 187:0387e8f68319 105 virtual int statvfs(const char *path, struct statvfs *buf);
AnnaBridge 167:e84263d55307 106 };
AnnaBridge 178:79309dc6340a 107 /**@}*/
AnnaBridge 167:e84263d55307 108
AnnaBridge 178:79309dc6340a 109 /**@}*/
AnnaBridge 167:e84263d55307 110
AnnaBridge 167:e84263d55307 111 } // namespace mbed
AnnaBridge 167:e84263d55307 112
AnnaBridge 167:e84263d55307 113 #endif