Backup 1

Committer:
borlanic
Date:
Tue Apr 24 11:45:18 2018 +0000
Revision:
0:02dd72d1d465
BaBoRo_test2 - backup 1

Who changed what in which revision?

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