Rtos API example

Committer:
marcozecchini
Date:
Sat Feb 23 12:13:36 2019 +0000
Revision:
0:9fca2b23d0ba
final commit

Who changed what in which revision?

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