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