BA / SerialCom

Fork of OmniWheels by Gustav Atmel

Committer:
gustavatmel
Date:
Tue May 01 15:47:08 2018 +0000
Revision:
1:9c5af431a1f1
sdf

Who changed what in which revision?

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