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