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_FILESYSTEMLIKE_H
marcozecchini 0:9fca2b23d0ba 17 #define MBED_FILESYSTEMLIKE_H
marcozecchini 0:9fca2b23d0ba 18
marcozecchini 0:9fca2b23d0ba 19 #include "platform/platform.h"
marcozecchini 0:9fca2b23d0ba 20
marcozecchini 0:9fca2b23d0ba 21 #include "platform/FileSystemHandle.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_FileSystemLike FileSystemLike 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 FileSystemLike : public FileSystemHandle, public FileBase, private NonCopyable<FileSystemLike> {
marcozecchini 0:9fca2b23d0ba 44 public:
marcozecchini 0:9fca2b23d0ba 45 /** FileSystemLike lifetime
marcozecchini 0:9fca2b23d0ba 46 */
marcozecchini 0:9fca2b23d0ba 47 FileSystemLike(const char *name = NULL) : FileBase(name, FileSystemPathType) {}
marcozecchini 0:9fca2b23d0ba 48 virtual ~FileSystemLike() {}
marcozecchini 0:9fca2b23d0ba 49
marcozecchini 0:9fca2b23d0ba 50 // Inherited functions with name conflicts
marcozecchini 0:9fca2b23d0ba 51 using FileSystemHandle::open;
marcozecchini 0:9fca2b23d0ba 52
marcozecchini 0:9fca2b23d0ba 53 /** Open a file on the filesystem
marcozecchini 0:9fca2b23d0ba 54 *
marcozecchini 0:9fca2b23d0ba 55 * @param path The name of the file to open
marcozecchini 0:9fca2b23d0ba 56 * @param flags The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR,
marcozecchini 0:9fca2b23d0ba 57 * bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND
marcozecchini 0:9fca2b23d0ba 58 * @return A file handle on success, NULL on failure
marcozecchini 0:9fca2b23d0ba 59 * @deprecated Replaced by `int open(FileHandle **, ...)` for propagating error codes
marcozecchini 0:9fca2b23d0ba 60 */
marcozecchini 0:9fca2b23d0ba 61 MBED_DEPRECATED_SINCE("mbed-os-5.5",
marcozecchini 0:9fca2b23d0ba 62 "Replaced by `int open(FileHandle **, ...)` for propagating error codes")
marcozecchini 0:9fca2b23d0ba 63 FileHandle *open(const char *path, int flags)
marcozecchini 0:9fca2b23d0ba 64 {
marcozecchini 0:9fca2b23d0ba 65 FileHandle *file;
marcozecchini 0:9fca2b23d0ba 66 int err = open(&file, path, flags);
marcozecchini 0:9fca2b23d0ba 67 return err ? NULL : file;
marcozecchini 0:9fca2b23d0ba 68 }
marcozecchini 0:9fca2b23d0ba 69
marcozecchini 0:9fca2b23d0ba 70 /** Open a directory on the filesystem
marcozecchini 0:9fca2b23d0ba 71 *
marcozecchini 0:9fca2b23d0ba 72 * @param path Name of the directory to open
marcozecchini 0:9fca2b23d0ba 73 * @return A directory handle on success, NULL on failure
marcozecchini 0:9fca2b23d0ba 74 * @deprecated Replaced by `int open(DirHandle **, ...)` for propagating error codes
marcozecchini 0:9fca2b23d0ba 75 */
marcozecchini 0:9fca2b23d0ba 76 MBED_DEPRECATED_SINCE("mbed-os-5.5",
marcozecchini 0:9fca2b23d0ba 77 "Replaced by `int open(DirHandle **, ...)` for propagating error codes")
marcozecchini 0:9fca2b23d0ba 78 DirHandle *opendir(const char *path)
marcozecchini 0:9fca2b23d0ba 79 {
marcozecchini 0:9fca2b23d0ba 80 DirHandle *dir;
marcozecchini 0:9fca2b23d0ba 81 int err = open(&dir, path);
marcozecchini 0:9fca2b23d0ba 82 return err ? NULL : dir;
marcozecchini 0:9fca2b23d0ba 83 }
marcozecchini 0:9fca2b23d0ba 84 };
marcozecchini 0:9fca2b23d0ba 85
marcozecchini 0:9fca2b23d0ba 86 /**@}*/
marcozecchini 0:9fca2b23d0ba 87
marcozecchini 0:9fca2b23d0ba 88 /**@}*/
marcozecchini 0:9fca2b23d0ba 89
marcozecchini 0:9fca2b23d0ba 90 } // namespace mbed
marcozecchini 0:9fca2b23d0ba 91
marcozecchini 0:9fca2b23d0ba 92 #endif