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