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