init

Dependencies:   mbed

Committer:
Nathan Yonkee
Date:
Fri Mar 02 07:16:49 2018 -0700
Revision:
10:46a4cf51ee38
Parent:
9:d58e77ebd769
remove mbed-os

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Nathan Yonkee 9:d58e77ebd769 1 /* mbed Microcontroller Library
Nathan Yonkee 9:d58e77ebd769 2 * Copyright (c) 2006-2013 ARM Limited
Nathan Yonkee 9:d58e77ebd769 3 *
Nathan Yonkee 9:d58e77ebd769 4 * Licensed under the Apache License, Version 2.0 (the "License");
Nathan Yonkee 9:d58e77ebd769 5 * you may not use this file except in compliance with the License.
Nathan Yonkee 9:d58e77ebd769 6 * You may obtain a copy of the License at
Nathan Yonkee 9:d58e77ebd769 7 *
Nathan Yonkee 9:d58e77ebd769 8 * http://www.apache.org/licenses/LICENSE-2.0
Nathan Yonkee 9:d58e77ebd769 9 *
Nathan Yonkee 9:d58e77ebd769 10 * Unless required by applicable law or agreed to in writing, software
Nathan Yonkee 9:d58e77ebd769 11 * distributed under the License is distributed on an "AS IS" BASIS,
Nathan Yonkee 9:d58e77ebd769 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Nathan Yonkee 9:d58e77ebd769 13 * See the License for the specific language governing permissions and
Nathan Yonkee 9:d58e77ebd769 14 * limitations under the License.
Nathan Yonkee 9:d58e77ebd769 15 */
Nathan Yonkee 9:d58e77ebd769 16 #ifndef MBED_FILESYSTEMLIKE_H
Nathan Yonkee 9:d58e77ebd769 17 #define MBED_FILESYSTEMLIKE_H
Nathan Yonkee 9:d58e77ebd769 18
Nathan Yonkee 9:d58e77ebd769 19 #include "platform/platform.h"
Nathan Yonkee 9:d58e77ebd769 20
Nathan Yonkee 9:d58e77ebd769 21 #include "platform/FileSystemHandle.h"
Nathan Yonkee 9:d58e77ebd769 22 #include "platform/FileHandle.h"
Nathan Yonkee 9:d58e77ebd769 23 #include "platform/DirHandle.h"
Nathan Yonkee 9:d58e77ebd769 24 #include "platform/NonCopyable.h"
Nathan Yonkee 9:d58e77ebd769 25
Nathan Yonkee 9:d58e77ebd769 26 namespace mbed {
Nathan Yonkee 9:d58e77ebd769 27 /** \addtogroup platform */
Nathan Yonkee 9:d58e77ebd769 28 /** @{*/
Nathan Yonkee 9:d58e77ebd769 29 /**
Nathan Yonkee 9:d58e77ebd769 30 * \defgroup platform_FileSystemLike FileSystemLike functions
Nathan Yonkee 9:d58e77ebd769 31 * @{
Nathan Yonkee 9:d58e77ebd769 32 */
Nathan Yonkee 9:d58e77ebd769 33
Nathan Yonkee 9:d58e77ebd769 34
Nathan Yonkee 9:d58e77ebd769 35 /** A filesystem-like object is one that can be used to open file-like
Nathan Yonkee 9:d58e77ebd769 36 * objects though it by fopen("/name/filename", mode)
Nathan Yonkee 9:d58e77ebd769 37 *
Nathan Yonkee 9:d58e77ebd769 38 * Implementations must define at least open (the default definitions
Nathan Yonkee 9:d58e77ebd769 39 * of the rest of the functions just return error values).
Nathan Yonkee 9:d58e77ebd769 40 *
Nathan Yonkee 9:d58e77ebd769 41 * @note Synchronization level: Set by subclass
Nathan Yonkee 9:d58e77ebd769 42 */
Nathan Yonkee 9:d58e77ebd769 43 class FileSystemLike : public FileSystemHandle, public FileBase, private NonCopyable<FileSystemLike> {
Nathan Yonkee 9:d58e77ebd769 44 public:
Nathan Yonkee 9:d58e77ebd769 45 /** FileSystemLike lifetime
Nathan Yonkee 9:d58e77ebd769 46 */
Nathan Yonkee 9:d58e77ebd769 47 FileSystemLike(const char *name = NULL) : FileBase(name, FileSystemPathType) {}
Nathan Yonkee 9:d58e77ebd769 48 virtual ~FileSystemLike() {}
Nathan Yonkee 9:d58e77ebd769 49
Nathan Yonkee 9:d58e77ebd769 50 // Inherited functions with name conflicts
Nathan Yonkee 9:d58e77ebd769 51 using FileSystemHandle::open;
Nathan Yonkee 9:d58e77ebd769 52
Nathan Yonkee 9:d58e77ebd769 53 /** Open a file on the filesystem
Nathan Yonkee 9:d58e77ebd769 54 *
Nathan Yonkee 9:d58e77ebd769 55 * @param path The name of the file to open
Nathan Yonkee 9:d58e77ebd769 56 * @param flags The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR,
Nathan Yonkee 9:d58e77ebd769 57 * bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND
Nathan Yonkee 9:d58e77ebd769 58 * @return A file handle on success, NULL on failure
Nathan Yonkee 9:d58e77ebd769 59 * @deprecated Replaced by `int open(FileHandle **, ...)` for propagating error codes
Nathan Yonkee 9:d58e77ebd769 60 */
Nathan Yonkee 9:d58e77ebd769 61 MBED_DEPRECATED_SINCE("mbed-os-5.5",
Nathan Yonkee 9:d58e77ebd769 62 "Replaced by `int open(FileHandle **, ...)` for propagating error codes")
Nathan Yonkee 9:d58e77ebd769 63 FileHandle *open(const char *path, int flags)
Nathan Yonkee 9:d58e77ebd769 64 {
Nathan Yonkee 9:d58e77ebd769 65 FileHandle *file;
Nathan Yonkee 9:d58e77ebd769 66 int err = open(&file, path, flags);
Nathan Yonkee 9:d58e77ebd769 67 return err ? NULL : file;
Nathan Yonkee 9:d58e77ebd769 68 }
Nathan Yonkee 9:d58e77ebd769 69
Nathan Yonkee 9:d58e77ebd769 70 /** Open a directory on the filesystem
Nathan Yonkee 9:d58e77ebd769 71 *
Nathan Yonkee 9:d58e77ebd769 72 * @param path Name of the directory to open
Nathan Yonkee 9:d58e77ebd769 73 * @return A directory handle on success, NULL on failure
Nathan Yonkee 9:d58e77ebd769 74 * @deprecated Replaced by `int open(DirHandle **, ...)` for propagating error codes
Nathan Yonkee 9:d58e77ebd769 75 */
Nathan Yonkee 9:d58e77ebd769 76 MBED_DEPRECATED_SINCE("mbed-os-5.5",
Nathan Yonkee 9:d58e77ebd769 77 "Replaced by `int open(DirHandle **, ...)` for propagating error codes")
Nathan Yonkee 9:d58e77ebd769 78 DirHandle *opendir(const char *path)
Nathan Yonkee 9:d58e77ebd769 79 {
Nathan Yonkee 9:d58e77ebd769 80 DirHandle *dir;
Nathan Yonkee 9:d58e77ebd769 81 int err = open(&dir, path);
Nathan Yonkee 9:d58e77ebd769 82 return err ? NULL : dir;
Nathan Yonkee 9:d58e77ebd769 83 }
Nathan Yonkee 9:d58e77ebd769 84 };
Nathan Yonkee 9:d58e77ebd769 85
Nathan Yonkee 9:d58e77ebd769 86 /**@}*/
Nathan Yonkee 9:d58e77ebd769 87
Nathan Yonkee 9:d58e77ebd769 88 /**@}*/
Nathan Yonkee 9:d58e77ebd769 89
Nathan Yonkee 9:d58e77ebd769 90 } // namespace mbed
Nathan Yonkee 9:d58e77ebd769 91
Nathan Yonkee 9:d58e77ebd769 92 #endif