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