mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FileSystemLike.h Source File

FileSystemLike.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef MBED_FILESYSTEMLIKE_H
00018 #define MBED_FILESYSTEMLIKE_H
00019 
00020 #include "platform/platform.h"
00021 
00022 #include "platform/FileSystemHandle.h"
00023 #include "platform/FileHandle.h"
00024 #include "platform/DirHandle.h"
00025 #include "platform/NonCopyable.h"
00026 
00027 namespace mbed {
00028 /** \addtogroup platform */
00029 /** @{*/
00030 /**
00031  * \defgroup platform_FileSystemLike FileSystemLike functions
00032  * @{
00033  */
00034 
00035 
00036 /** A filesystem-like object is one that can be used to open file-like
00037  *  objects though it by fopen("/name/filename", mode)
00038  *
00039  *  Implementations must define at least open (the default definitions
00040  *  of the rest of the functions just return error values).
00041  *
00042  * @note Synchronization level: Set by subclass
00043  */
00044 class FileSystemLike : public FileSystemHandle, public FileBase, private NonCopyable<FileSystemLike> {
00045 public:
00046     /** FileSystemLike lifetime
00047      */
00048     FileSystemLike(const char *name = NULL) : FileBase(name, FileSystemPathType) {}
00049     virtual ~FileSystemLike() {}
00050 
00051     // Inherited functions with name conflicts
00052     using FileSystemHandle::open;
00053 
00054     /** Open a file on the filesystem
00055      *
00056      *  @param path     The name of the file to open
00057      *  @param flags    The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR,
00058      *                  bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND
00059      *  @return         A file handle on success, NULL on failure
00060      *  @deprecated Replaced by `int open(FileHandle **, ...)` for propagating error codes
00061      */
00062     MBED_DEPRECATED_SINCE("mbed-os-5.5",
00063                           "Replaced by `int open(FileHandle **, ...)` for propagating error codes")
00064     FileHandle *open(const char *path, int flags)
00065     {
00066         FileHandle *file;
00067         int err = open(&file, path, flags);
00068         return err ? NULL : file;
00069     }
00070 
00071     /** Open a directory on the filesystem
00072      *
00073      *  @param path     Name of the directory to open
00074      *  @return         A directory handle on success, NULL on failure
00075      *  @deprecated Replaced by `int open(DirHandle **, ...)` for propagating error codes
00076      */
00077     MBED_DEPRECATED_SINCE("mbed-os-5.5",
00078                           "Replaced by `int open(DirHandle **, ...)` for propagating error codes")
00079     DirHandle *opendir(const char *path)
00080     {
00081         DirHandle *dir;
00082         int err = open(&dir, path);
00083         return err ? NULL : dir;
00084     }
00085 };
00086 
00087 /**@}*/
00088 
00089 /**@}*/
00090 
00091 } // namespace mbed
00092 
00093 #endif