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