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