Mistake on this page?
Report an issue in GitHub or email us
FileSystemHandle.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2013 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_FILESYSTEMHANDLE_H
18 #define MBED_FILESYSTEMHANDLE_H
19 
20 #include "platform/platform.h"
21 
22 #include "platform/FileBase.h"
23 #include "platform/FileHandle.h"
24 #include "platform/DirHandle.h"
25 #include "platform/NonCopyable.h"
26 
27 namespace mbed {
28 /** \addtogroup platform */
29 /** @{*/
30 /**
31  * \defgroup platform_FileSystemHandle FileSystemHandle functions
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 FileSystemHandle : private NonCopyable<FileSystemHandle> {
45 public:
46  /** FileSystemHandle lifetime
47  */
48  virtual ~FileSystemHandle() {}
49 
50  /** Open a file on the filesystem
51  *
52  * @param file Destination for the handle to a newly created file
53  * @param filename The name of the file to open
54  * @param flags The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR,
55  * bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND
56  * @return 0 on success, negative error code on failure
57  */
58  virtual int open(FileHandle **file, const char *filename, int flags) = 0;
59 
60  /** Open a directory on the filesystem
61  *
62  * @param dir Destination for the handle to the directory
63  * @param path Name of the directory to open
64  * @return 0 on success, negative error code on failure
65  */
66  virtual int open(DirHandle **dir, const char *path);
67 
68  /** Remove a file from the filesystem.
69  *
70  * @param path The name of the file to remove.
71  * @return 0 on success, negative error code on failure
72  */
73  virtual int remove(const char *path);
74 
75  /** Rename a file in the filesystem.
76  *
77  * @param path The name of the file to rename.
78  * @param newpath The name to rename it to
79  * @return 0 on success, negative error code on failure
80  */
81  virtual int rename(const char *path, const char *newpath);
82 
83  /** Store information about the file in a stat structure
84  *
85  * @param path The name of the file to find information about
86  * @param st The stat buffer to write to
87  * @return 0 on success, negative error code on failure
88  */
89  virtual int stat(const char *path, struct stat *st);
90 
91  /** Create a directory in the filesystem.
92  *
93  * @param path The name of the directory to create.
94  * @param mode The permissions with which to create the directory
95  * @return 0 on success, negative error code on failure
96  */
97  virtual int mkdir(const char *path, mode_t mode);
98 
99  /** Store information about the mounted filesystem in a statvfs structure
100  *
101  * @param path The name of the file to find information about
102  * @param buf The stat buffer to write to
103  * @return 0 on success, negative error code on failure
104  */
105  virtual int statvfs(const char *path, struct statvfs *buf);
106 };
107 /**@}*/
108 
109 /**@}*/
110 
111 } // namespace mbed
112 
113 #endif
Represents a directory stream.
Definition: DirHandle.h:56
virtual ~FileSystemHandle()
FileSystemHandle lifetime.
virtual int open(FileHandle **file, const char *filename, int flags)=0
Open a file on the filesystem.
Class FileHandle.
Definition: FileHandle.h:46
Prevents generation of copy constructor and copy assignment operator in derived classes.
Definition: NonCopyable.h:168
virtual int stat(const char *path, struct stat *st)
Store information about the file in a stat structure.
A filesystem-like object is one that can be used to open file-like objects though it by fopen("/name/...
virtual int statvfs(const char *path, struct statvfs *buf)
Store information about the mounted filesystem in a statvfs structure.
virtual int rename(const char *path, const char *newpath)
Rename a file in the filesystem.
virtual int mkdir(const char *path, mode_t mode)
Create a directory in the filesystem.
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.