mbed-os

Dependents:   cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more

Committer:
be_bryan
Date:
Mon Dec 11 17:54:04 2017 +0000
Revision:
0:b74591d5ab33
motor ++

Who changed what in which revision?

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