The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
170:e95d10626187
mbed library release version 165

Who changed what in which revision?

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