BBR 1 Ebene

Committer:
borlanic
Date:
Mon May 14 11:29:06 2018 +0000
Revision:
0:fbdae7e6d805
BBR

Who changed what in which revision?

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