Skip to content

Commit eed1cec

Browse files
gekyc1728p9
authored andcommitted
FileSystem: Provided default implementations for all non-file operations
1 parent 5d6fc71 commit eed1cec

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

features/filesystem/FileSystem.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/* mbed Microcontroller Library
32
* Copyright (c) 2006-2013 ARM Limited
43
*
@@ -25,6 +24,26 @@ FileSystem::FileSystem(const char *name)
2524
{
2625
}
2726

27+
int FileSystem::remove(const char *path)
28+
{
29+
return -ENOSYS;
30+
}
31+
32+
int FileSystem::rename(const char *path, const char *newpath)
33+
{
34+
return -ENOSYS;
35+
}
36+
37+
int FileSystem::stat(const char *path, struct stat *st)
38+
{
39+
return -ENOSYS;
40+
}
41+
42+
int FileSystem::mkdir(const char *path, mode_t mode)
43+
{
44+
return -ENOSYS;
45+
}
46+
2847
int FileSystem::file_sync(fs_file_t file)
2948
{
3049
return 0;
@@ -53,11 +72,6 @@ off_t FileSystem::file_size(fs_file_t file)
5372
return size;
5473
}
5574

56-
int FileSystem::mkdir(const char *path, mode_t mode)
57-
{
58-
return -ENOSYS;
59-
}
60-
6175
int FileSystem::dir_open(fs_dir_t *dir, const char *path)
6276
{
6377
return -ENOSYS;

features/filesystem/FileSystem.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,23 @@ class FileSystem : public FileSystemLike {
7171
* @param path The name of the file to remove.
7272
* @return 0 on success, negative error code on failure
7373
*/
74-
virtual int remove(const char *path) = 0;
74+
virtual int remove(const char *path);
7575

7676
/** Rename a file in the filesystem.
7777
*
7878
* @param path The name of the file to rename.
7979
* @param newpath The name to rename it to
8080
* @return 0 on success, negative error code on failure
8181
*/
82-
virtual int rename(const char *path, const char *newpath) = 0;
82+
virtual int rename(const char *path, const char *newpath);
8383

8484
/** Store information about the file in a stat structure
8585
*
8686
* @param path The name of the file to find information about
8787
* @param st The stat buffer to write to
8888
* @return 0 on success, negative error code on failure
8989
*/
90-
virtual int stat(const char *path, struct stat *st) = 0;
90+
virtual int stat(const char *path, struct stat *st);
9191

9292
/** Create a directory in the filesystem.
9393
*

0 commit comments

Comments
 (0)