26
26
#include " BlockDevice.h"
27
27
28
28
namespace mbed {
29
- /* * \addtogroup filesystem */
29
+ /* * \addtogroup file system */
30
30
/* * @{*/
31
31
32
32
33
- // Opaque pointer representing files and directories
33
+ // Opaque pointer representing files and directories.
34
34
typedef void *fs_file_t ;
35
35
typedef void *fs_dir_t ;
36
36
37
- // Predeclared classes
37
+ // Predeclared classes.
38
38
class Dir ;
39
39
class File ;
40
40
41
- /* * A filesystem object provides filesystem operations and file operations
41
+ /* * A file system object. Provides file system operations and file operations
42
42
* for the File and Dir classes on a block device.
43
43
*
44
44
* Implementations must provide at minimum file operations and mount
@@ -49,174 +49,174 @@ class File;
49
49
class FileSystem : public FileSystemLike {
50
50
public:
51
51
52
- /* * FileSystem lifetime
52
+ /* * File system lifetime.
53
53
*
54
- * @param name Name to add filesystem to tree as
54
+ * @param name Name to add file system to tree as.
55
55
*/
56
56
FileSystem (const char *name = NULL );
57
57
virtual ~FileSystem () {}
58
58
59
- /* * Return the default filesystem
59
+ /* * Return the default file system.
60
60
*
61
- * Returns the default FileSystem base on the default BlockDevice configuration.
61
+ * Returns the default file system based on the default block device configuration.
62
62
* Use the components in target.json or application config to change
63
63
* the default block device and affect the default filesystem.
64
64
* SD block device => FAT filesystem
65
- * SPIF block device => LITTLE filesystem
66
- * DATAFLASH block device => LITTLE filesystem
65
+ * QSPIF, SPIF, DATAFLASH or FLAHIAP block device => LITTLE filesystem
67
66
*
68
67
* An application can override all target settings by implementing
69
- * FileSystem::get_default_instance() themselves - the default
68
+ * FileSystem::get_default_instance() - the default
70
69
* definition is weak, and calls get_target_default_instance().
71
70
*/
72
71
static FileSystem *get_default_instance ();
73
72
74
- /* * Mounts a filesystem to a block device
73
+ /* * Mount a file system to a block device.
75
74
*
76
- * @param bd BlockDevice to mount to
77
- * @return 0 on success, negative error code on failure
75
+ * @param bd Block device to mount to.
76
+ * @return 0 on success, negative error code on failure.
78
77
*/
79
78
virtual int mount (BlockDevice *bd) = 0;
80
79
81
- /* * Unmounts a filesystem from the underlying block device
80
+ /* * Unmount a file system from the underlying block device.
82
81
*
83
- * @return 0 on success, negative error code on failure
82
+ * @return 0 on success, negative error code on failure.
84
83
*/
85
84
virtual int unmount () = 0;
86
85
87
- /* * Reformats a filesystem, results in an empty and mounted filesystem
86
+ /* * Reformat a file system. Results in an empty and mounted file system.
88
87
*
89
- * @param bd BlockDevice to reformat and mount. If NULL, the mounted
90
- * block device will be used.
91
- * Note: if mount fails, bd must be provided.
88
+ * @param bd Block device to reformat and mount. If NULL, the mounted
89
+ * Block device is used.
90
+ * Note: If mount fails, bd must be provided.
92
91
* Default: NULL
93
- * @return 0 on success, negative error code on failure
92
+ * @return 0 on success, negative error code on failure.
94
93
*/
95
94
virtual int reformat (BlockDevice *bd = NULL );
96
95
97
- /* * Remove a file from the filesystem .
96
+ /* * Remove a file from the file system .
98
97
*
99
98
* @param path The name of the file to remove.
100
- * @return 0 on success, negative error code on failure
99
+ * @return 0 on success, negative error code on failure.
101
100
*/
102
101
virtual int remove (const char *path);
103
102
104
- /* * Rename a file in the filesystem .
103
+ /* * Rename a file in the file system .
105
104
*
106
- * @param path The name of the file to rename.
107
- * @param newpath The name to rename it to
108
- * @return 0 on success, negative error code on failure
105
+ * @param path The existing name of the file to rename.
106
+ * @param newpath The new name of the file.
107
+ * @return 0 on success, negative error code on failure.
109
108
*/
110
109
virtual int rename (const char *path, const char *newpath);
111
110
112
- /* * Store information about the file in a stat structure
111
+ /* * Store information about the file in a stat structure.
113
112
*
114
- * @param path The name of the file to find information about
115
- * @param st The stat buffer to write to
116
- * @return 0 on success, negative error code on failure
113
+ * @param path The name of the file to find information about.
114
+ * @param st The stat buffer to write to.
115
+ * @return 0 on success, negative error code on failure.
117
116
*/
118
117
virtual int stat (const char *path, struct stat *st);
119
118
120
- /* * Create a directory in the filesystem .
119
+ /* * Create a directory in the file system .
121
120
*
122
121
* @param path The name of the directory to create.
123
- * @param mode The permissions with which to create the directory
124
- * @return 0 on success, negative error code on failure
122
+ * @param mode The permissions with which to create the directory.
123
+ * @return 0 on success, negative error code on failure.
125
124
*/
126
125
virtual int mkdir (const char *path, mode_t mode);
127
126
128
- /* * Store information about the mounted filesystem in a statvfs structure
127
+ /* * Store information about the mounted file system in a statvfs structure.
129
128
*
130
- * @param path The name of the file to find information about
131
- * @param buf The stat buffer to write to
132
- * @return 0 on success, negative error code on failure
129
+ * @param path The name of the file to find information about.
130
+ * @param buf The stat buffer to write to.
131
+ * @return 0 on success, negative error code on failure.
133
132
*/
134
133
virtual int statvfs (const char *path, struct statvfs *buf);
135
134
136
135
protected:
137
136
friend class File ;
138
137
friend class Dir ;
139
138
140
- /* * Open a file on the filesystem
139
+ #if !(DOXYGEN_ONLY)
140
+ /* * Open a file on the file system.
141
141
*
142
- * @param file Destination for the handle to a newly created file
143
- * @param path The name of the file to open
144
- * @param flags The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR,
145
- * bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND
146
- * @return 0 on success, negative error code on failure
142
+ * @param file Destination of the newly created handle to the referenced file.
143
+ * @param path The name of the file to open.
144
+ * @param flags The flags that trigger opening of the file. These flags are O_RDONLY, O_WRONLY, and O_RDWR,
145
+ * with an O_CREAT, O_TRUNC, or O_APPEND bitwise OR operator.
146
+ * @return 0 on success, negative error code on failure.
147
147
*/
148
148
virtual int file_open (fs_file_t *file, const char *path, int flags) = 0;
149
149
150
- /* * Close a file
150
+ /* * Close a file.
151
151
*
152
- * @param file File handle
153
- * @ return 0 on success, negative error code on failure
152
+ * @param file File handle.
153
+ * return 0 on success, negative error code on failure.
154
154
*/
155
155
virtual int file_close (fs_file_t file) = 0;
156
156
157
- /* * Read the contents of a file into a buffer
157
+ /* * Read the contents of a file into a buffer.
158
158
*
159
- * @param file File handle
160
- * @param buffer The buffer to read in to
161
- * @param size The number of bytes to read
162
- * @return The number of bytes read, 0 at end of file, negative error on failure
159
+ * @param file File handle.
160
+ * @param buffer The buffer to read in to.
161
+ * @param size The number of bytes to read.
162
+ * @return The number of bytes read, 0 at the end of the file, negative error on failure.
163
163
*/
164
164
virtual ssize_t file_read (fs_file_t file, void *buffer, size_t size) = 0;
165
165
166
- /* * Write the contents of a buffer to a file
166
+ /* * Write the contents of a buffer to a file.
167
167
*
168
- * @param file File handle
169
- * @param buffer The buffer to write from
170
- * @param size The number of bytes to write
171
- * @return The number of bytes written, negative error on failure
168
+ * @param file File handle.
169
+ * @param buffer The buffer to write from.
170
+ * @param size The number of bytes to write.
171
+ * @return The number of bytes written, negative error on failure.
172
172
*/
173
173
virtual ssize_t file_write (fs_file_t file, const void *buffer, size_t size) = 0;
174
174
175
- /* * Flush any buffers associated with the file
175
+ /* * Flush any buffers associated with the file.
176
176
*
177
- * @param file File handle
178
- * @return 0 on success, negative error code on failure
177
+ * @param file File handle.
178
+ * @return 0 on success, negative error code on failure.
179
179
*/
180
180
virtual int file_sync (fs_file_t file);
181
181
182
- /* * Check if the file in an interactive terminal device
183
- * If so, line buffered behaviour is used by default
182
+ /* * Check whether the file is an interactive terminal device.
183
+ * If so, line buffered behavior is used by default.
184
184
*
185
- * @param file File handle
186
- * @return True if the file is a terminal
185
+ * @param file File handle.
186
+ * @return True if the file is a terminal.
187
187
*/
188
188
virtual int file_isatty (fs_file_t file);
189
189
190
- /* * Move the file position to a given offset from from a given location
190
+ /* * Move the file position to a given offset from a given location.
191
191
*
192
- * @param file File handle
193
- * @param offset The offset from whence to move to
194
- * @param whence The start of where to seek
195
- * SEEK_SET to start from beginning of file,
196
- * SEEK_CUR to start from current position in file,
197
- * SEEK_END to start from end of file
192
+ * @param file File handle.
193
+ * @param offset The offset from whence to move to.
194
+ * @param whence The start of where to seek.
195
+ * SEEK_SET to start from the beginning of the file,
196
+ * SEEK_CUR to start from the current position in the file,
197
+ * SEEK_END to start from the end of the file.
198
198
* @return The new offset of the file
199
199
*/
200
200
virtual off_t file_seek (fs_file_t file, off_t offset, int whence) = 0;
201
201
202
- /* * Get the file position of the file
202
+ /* * Get the file position of the file.
203
203
*
204
- * @param file File handle
205
- * @return The current offset in the file
204
+ * @param file File handle.
205
+ * @return The current offset in the file.
206
206
*/
207
207
virtual off_t file_tell (fs_file_t file);
208
208
209
- /* * Rewind the file position to the beginning of the file
209
+ /* * Rewind the file position to the beginning of the file.
210
210
*
211
- * @param file File handle
211
+ * @param file File handle.
212
212
* @note This is equivalent to file_seek(file, 0, FS_SEEK_SET)
213
213
*/
214
214
virtual void file_rewind (fs_file_t file);
215
215
216
- /* * Get the size of the file
216
+ /* * Get the size of the file.
217
217
*
218
- * @param file File handle
219
- * @return Size of the file in bytes
218
+ * @param file File handle.
219
+ * @return Size of the file in bytes.
220
220
*/
221
221
virtual off_t file_size (fs_file_t file);
222
222
@@ -226,66 +226,67 @@ class FileSystem : public FileSystemLike {
226
226
* not changed. If the file is extended, the extended area appears as if
227
227
* it were zero-filled.
228
228
*
229
- * @param file File handle
230
- * @param length The requested new length for the file
229
+ * @param file File handle.
230
+ * @param length The requested new length for the file.
231
231
*
232
- * @return Zero on success, negative error code on failure
232
+ * @return 0 on success, negative error code on failure.
233
233
*/
234
234
virtual int file_truncate (fs_file_t file, off_t length);
235
235
236
- /* * Open a directory on the filesystem
236
+ /* * Open a directory on the file system.
237
237
*
238
- * @param dir Destination for the handle to the directory
239
- * @param path Name of the directory to open
240
- * @return 0 on success, negative error code on failure
238
+ * @param dir Destination for the handle to the directory.
239
+ * @param path Name of the directory to open.
240
+ * @return 0 on success, negative error code on failure.
241
241
*/
242
242
virtual int dir_open (fs_dir_t *dir, const char *path);
243
243
244
- /* * Close a directory
244
+ /* * Close a directory.
245
245
*
246
- * @param dir Dir handle
247
- * @return 0 on success, negative error code on failure
246
+ * @param dir Dir handle.
247
+ * @return 0 on success, negative error code on failure.
248
248
*/
249
249
virtual int dir_close (fs_dir_t dir);
250
250
251
- /* * Read the next directory entry
251
+ /* * Read the next directory entry.
252
252
*
253
- * @param dir Dir handle
254
- * @param ent The directory entry to fill out
255
- * @return 1 on reading a filename, 0 at end of directory, negative error on failure
253
+ * @param dir Dir handle.
254
+ * @param ent The directory entry to fill out.
255
+ * @return 1 on reading a filename, 0 at the end of the directory, negative error on failure.
256
256
*/
257
257
virtual ssize_t dir_read (fs_dir_t dir, struct dirent *ent);
258
258
259
- /* * Set the current position of the directory
259
+ /* * Set the current position of the directory.
260
260
*
261
- * @param dir Dir handle
261
+ * @param dir Dir handle.
262
262
* @param offset Offset of the location to seek to,
263
- * must be a value returned from dir_tell
263
+ * must be a value returned from dir_tell.
264
264
*/
265
265
virtual void dir_seek (fs_dir_t dir, off_t offset);
266
266
267
- /* * Get the current position of the directory
267
+ /* * Get the current position of the directory.
268
268
*
269
- * @param dir Dir handle
270
- * @return Position of the directory that can be passed to dir_rewind
269
+ * @param dir Dir handle.
270
+ * @return Directory position, which can be passed to dir_rewind.
271
271
*/
272
272
virtual off_t dir_tell (fs_dir_t dir);
273
273
274
- /* * Rewind the current position to the beginning of the directory
274
+ /* * Rewind the current position to the beginning of the directory.
275
275
*
276
- * @param dir Dir handle
276
+ * @param dir Dir handle.
277
277
*/
278
278
virtual void dir_rewind (fs_dir_t dir);
279
279
280
- /* * Get the sizeof the directory
280
+ /* * Get the size of the directory.
281
281
*
282
- * @param dir Dir handle
283
- * @return Number of files in the directory
282
+ * @param dir Dir handle.
283
+ * @return Number of files in the directory.
284
284
*/
285
285
virtual size_t dir_size (fs_dir_t dir);
286
+ #endif // !defined(DOXYGEN_ONLY)
286
287
287
288
protected:
288
- // Hooks for FileSystemHandle
289
+ // Hooks for file systemHandle
289
290
virtual int open (FileHandle **file, const char *path, int flags);
290
291
virtual int open (DirHandle **dir, const char *path);
291
292
};
0 commit comments