29
29
#include < stdint.h>
30
30
#include " PlatformMutex.h"
31
31
32
+ namespace mbed {
33
+
32
34
/* *
33
35
* FATFileSystem based on ChaN's Fat Filesystem library v0.8
34
36
*/
35
- class FATFileSystem : public mbed :: FileSystem {
37
+ class FATFileSystem : public FileSystem {
36
38
public:
37
39
/* * Lifetime of the FATFileSystem
38
40
*
39
41
* @param name Name to add filesystem to tree as
40
42
* @param bd BlockDevice to mount, may be passed instead to mount call
41
43
*/
42
- FATFileSystem (const char *name = NULL , mbed:: BlockDevice *bd = NULL );
44
+ FATFileSystem (const char *name = NULL , BlockDevice *bd = NULL );
43
45
virtual ~FATFileSystem ();
44
46
45
47
/* * Formats a logical drive, FDISK partitioning rule.
@@ -58,14 +60,14 @@ class FATFileSystem : public mbed::FileSystem {
58
60
*
59
61
* @return 0 on success, negative error code on failure
60
62
*/
61
- static int format (mbed:: BlockDevice *bd, mbed:: bd_size_t cluster_size = 0 );
63
+ static int format (BlockDevice *bd, bd_size_t cluster_size = 0 );
62
64
63
65
/* * Mounts a filesystem to a block device
64
66
*
65
67
* @param bd BlockDevice to mount to
66
68
* @return 0 on success, negative error code on failure
67
69
*/
68
- virtual int mount (mbed:: BlockDevice *bd);
70
+ virtual int mount (BlockDevice *bd);
69
71
70
72
/* * Unmounts a filesystem from the underlying block device
71
73
*
@@ -90,7 +92,7 @@ class FATFileSystem : public mbed::FileSystem {
90
92
*
91
93
* @return 0 on success, negative error code on failure
92
94
*/
93
- virtual int reformat (mbed:: BlockDevice *bd, int allocation_unit);
95
+ virtual int reformat (BlockDevice *bd, int allocation_unit);
94
96
95
97
/* * Reformats a filesystem, results in an empty and mounted filesystem
96
98
*
@@ -100,7 +102,7 @@ class FATFileSystem : public mbed::FileSystem {
100
102
* Default: NULL
101
103
* @return 0 on success, negative error code on failure
102
104
*/
103
- virtual int reformat (mbed:: BlockDevice *bd = NULL )
105
+ virtual int reformat (BlockDevice *bd = NULL )
104
106
{
105
107
// required for virtual inheritance shenanigans
106
108
return reformat (bd, 0 );
@@ -154,14 +156,14 @@ class FATFileSystem : public mbed::FileSystem {
154
156
* bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND
155
157
* @return 0 on success, negative error code on failure
156
158
*/
157
- virtual int file_open (mbed:: fs_file_t *file, const char *path, int flags);
159
+ virtual int file_open (fs_file_t *file, const char *path, int flags);
158
160
159
161
/* * Close a file
160
162
*
161
163
* @param file File handle
162
164
* @return 0 on success, negative error code on failure
163
165
*/
164
- virtual int file_close (mbed:: fs_file_t file);
166
+ virtual int file_close (fs_file_t file);
165
167
166
168
/* * Read the contents of a file into a buffer
167
169
*
@@ -170,7 +172,7 @@ class FATFileSystem : public mbed::FileSystem {
170
172
* @param len The number of bytes to read
171
173
* @return The number of bytes read, 0 at end of file, negative error on failure
172
174
*/
173
- virtual ssize_t file_read (mbed:: fs_file_t file, void *buffer, size_t len);
175
+ virtual ssize_t file_read (fs_file_t file, void *buffer, size_t len);
174
176
175
177
/* * Write the contents of a buffer to a file
176
178
*
@@ -179,14 +181,14 @@ class FATFileSystem : public mbed::FileSystem {
179
181
* @param len The number of bytes to write
180
182
* @return The number of bytes written, negative error on failure
181
183
*/
182
- virtual ssize_t file_write (mbed:: fs_file_t file, const void *buffer, size_t len);
184
+ virtual ssize_t file_write (fs_file_t file, const void *buffer, size_t len);
183
185
184
186
/* * Flush any buffers associated with the file
185
187
*
186
188
* @param file File handle
187
189
* @return 0 on success, negative error code on failure
188
190
*/
189
- virtual int file_sync (mbed:: fs_file_t file);
191
+ virtual int file_sync (fs_file_t file);
190
192
191
193
/* * Move the file position to a given offset from from a given location
192
194
*
@@ -198,65 +200,65 @@ class FATFileSystem : public mbed::FileSystem {
198
200
* SEEK_END to start from end of file
199
201
* @return The new offset of the file
200
202
*/
201
- virtual off_t file_seek (mbed:: fs_file_t file, off_t offset, int whence);
203
+ virtual off_t file_seek (fs_file_t file, off_t offset, int whence);
202
204
203
205
/* * Get the file position of the file
204
206
*
205
207
* @param file File handle
206
208
* @return The current offset in the file
207
209
*/
208
- virtual off_t file_tell (mbed:: fs_file_t file);
210
+ virtual off_t file_tell (fs_file_t file);
209
211
210
212
/* * Get the size of the file
211
213
*
212
214
* @param file File handle
213
215
* @return Size of the file in bytes
214
216
*/
215
- virtual off_t file_size (mbed:: fs_file_t file);
217
+ virtual off_t file_size (fs_file_t file);
216
218
217
219
/* * Open a directory on the filesystem
218
220
*
219
221
* @param dir Destination for the handle to the directory
220
222
* @param path Name of the directory to open
221
223
* @return 0 on success, negative error code on failure
222
224
*/
223
- virtual int dir_open (mbed:: fs_dir_t *dir, const char *path);
225
+ virtual int dir_open (fs_dir_t *dir, const char *path);
224
226
225
227
/* * Close a directory
226
228
*
227
229
* @param dir Dir handle
228
230
* @return 0 on success, negative error code on failure
229
231
*/
230
- virtual int dir_close (mbed:: fs_dir_t dir);
232
+ virtual int dir_close (fs_dir_t dir);
231
233
232
234
/* * Read the next directory entry
233
235
*
234
236
* @param dir Dir handle
235
237
* @param ent The directory entry to fill out
236
238
* @return 1 on reading a filename, 0 at end of directory, negative error on failure
237
239
*/
238
- virtual ssize_t dir_read (mbed:: fs_dir_t dir, struct dirent *ent);
240
+ virtual ssize_t dir_read (fs_dir_t dir, struct dirent *ent);
239
241
240
242
/* * Set the current position of the directory
241
243
*
242
244
* @param dir Dir handle
243
245
* @param offset Offset of the location to seek to,
244
246
* must be a value returned from dir_tell
245
247
*/
246
- virtual void dir_seek (mbed:: fs_dir_t dir, off_t offset);
248
+ virtual void dir_seek (fs_dir_t dir, off_t offset);
247
249
248
250
/* * Get the current position of the directory
249
251
*
250
252
* @param dir Dir handle
251
253
* @return Position of the directory that can be passed to dir_rewind
252
254
*/
253
- virtual off_t dir_tell (mbed:: fs_dir_t dir);
255
+ virtual off_t dir_tell (fs_dir_t dir);
254
256
255
257
/* * Rewind the current position to the beginning of the directory
256
258
*
257
259
* @param dir Dir handle
258
260
*/
259
- virtual void dir_rewind (mbed:: fs_dir_t dir);
261
+ virtual void dir_rewind (fs_dir_t dir);
260
262
261
263
private:
262
264
FATFS _fs; // Work area (file system object) for logical drive
@@ -266,7 +268,9 @@ class FATFileSystem : public mbed::FileSystem {
266
268
protected:
267
269
virtual void lock ();
268
270
virtual void unlock ();
269
- virtual int mount (mbed:: BlockDevice *bd, bool mount);
271
+ virtual int mount (BlockDevice *bd, bool mount);
270
272
};
271
273
274
+ } // namespace mbed
275
+
272
276
#endif
0 commit comments