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:
Kojto
Date:
Wed Jul 19 16:46:19 2017 +0100
Revision:
147:a97add6d7e64
Parent:
146:22da6e220af6
Release 147 of the mbed library.

Who changed what in which revision?

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