test

Fork of mbed-dev by mbed official

Committer:
AnnaBridge
Date:
Wed Nov 08 13:50:44 2017 +0000
Revision:
178:d650f5d4c87a
Parent:
169:9672193075cf
This updates the lib to the mbed lib v 155

Who changed what in which revision?

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