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

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.