diff --git a/mongoose.c b/mongoose.c index 0023cfd3..584546a0 100644 --- a/mongoose.c +++ b/mongoose.c @@ -907,54 +907,6 @@ bool mg_file_printf(struct mg_fs *fs, const char *path, const char *fmt, ...) { return result; } -#ifdef MG_ENABLE_LINES -#line 1 "src/fs_dummy.c" -#endif - - -static int d_stat(const char *path, size_t *size, time_t *mtime) { - (void) path, (void) size, (void) mtime; - return 0; -} -static void d_list(const char *path, void (*fn)(const char *, void *), - void *userdata) { - (void) path, (void) fn, (void) userdata; -} -static void *d_open(const char *path, int flags) { - (void) path, (void) flags; - return NULL; -} -static void d_close(void *fp) { - (void) fp; -} -static size_t d_read(void *fd, void *buf, size_t len) { - (void) fd, (void) buf, (void) len; - return 0; -} -static size_t d_write(void *fd, const void *buf, size_t len) { - (void) fd, (void) buf, (void) len; - return 0; -} -static size_t d_seek(void *fd, size_t offset) { - (void) fd, (void) offset; - return (size_t) ~0; -} -static bool d_rename(const char *from, const char *to) { - (void) from, (void) to; - return false; -} -static bool d_remove(const char *path) { - (void) path; - return false; -} -static bool d_mkdir(const char *path) { - (void) path; - return false; -} - -struct mg_fs mg_fs_dummy = {d_stat, d_list, d_open, d_close, d_read, - d_write, d_seek, d_rename, d_remove, d_mkdir}; - #ifdef MG_ENABLE_LINES #line 1 "src/fs_fat.c" #endif @@ -1413,6 +1365,47 @@ static bool p_mkdir(const char *path) { return mkdir(path, 0775) == 0; } +#else + +static int p_stat(const char *path, size_t *size, time_t *mtime) { + (void) path, (void) size, (void) mtime; + return 0; +} +static void p_list(const char *path, void (*fn)(const char *, void *), + void *userdata) { + (void) path, (void) fn, (void) userdata; +} +static void *p_open(const char *path, int flags) { + (void) path, (void) flags; + return NULL; +} +static void p_close(void *fp) { + (void) fp; +} +static size_t p_read(void *fd, void *buf, size_t len) { + (void) fd, (void) buf, (void) len; + return 0; +} +static size_t p_write(void *fd, const void *buf, size_t len) { + (void) fd, (void) buf, (void) len; + return 0; +} +static size_t p_seek(void *fd, size_t offset) { + (void) fd, (void) offset; + return (size_t) ~0; +} +static bool p_rename(const char *from, const char *to) { + (void) from, (void) to; + return false; +} +static bool p_remove(const char *path) { + (void) path; + return false; +} +static bool p_mkdir(const char *path) { + (void) path; + return false; +} #endif struct mg_fs mg_fs_posix = {p_stat, p_list, p_open, p_close, p_read, diff --git a/mongoose.h b/mongoose.h index 04b59367..0b537e0c 100644 --- a/mongoose.h +++ b/mongoose.h @@ -821,7 +821,6 @@ struct mg_fs { bool (*mkd)(const char *path); // Create directory }; -extern struct mg_fs mg_fs_dummy; // Dummy FS, does nothing extern struct mg_fs mg_fs_posix; // POSIX open/close/read/write/seek extern struct mg_fs mg_fs_packed; // Packed FS, see examples/device-dashboard extern struct mg_fs mg_fs_fat; // FAT FS diff --git a/src/fs.h b/src/fs.h index d16d9c31..bd4393be 100644 --- a/src/fs.h +++ b/src/fs.h @@ -25,7 +25,6 @@ struct mg_fs { bool (*mkd)(const char *path); // Create directory }; -extern struct mg_fs mg_fs_dummy; // Dummy FS, does nothing extern struct mg_fs mg_fs_posix; // POSIX open/close/read/write/seek extern struct mg_fs mg_fs_packed; // Packed FS, see examples/device-dashboard extern struct mg_fs mg_fs_fat; // FAT FS diff --git a/src/fs_dummy.c b/src/fs_dummy.c deleted file mode 100644 index 2ee3d78b..00000000 --- a/src/fs_dummy.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "fs.h" - -static int d_stat(const char *path, size_t *size, time_t *mtime) { - (void) path, (void) size, (void) mtime; - return 0; -} -static void d_list(const char *path, void (*fn)(const char *, void *), - void *userdata) { - (void) path, (void) fn, (void) userdata; -} -static void *d_open(const char *path, int flags) { - (void) path, (void) flags; - return NULL; -} -static void d_close(void *fp) { - (void) fp; -} -static size_t d_read(void *fd, void *buf, size_t len) { - (void) fd, (void) buf, (void) len; - return 0; -} -static size_t d_write(void *fd, const void *buf, size_t len) { - (void) fd, (void) buf, (void) len; - return 0; -} -static size_t d_seek(void *fd, size_t offset) { - (void) fd, (void) offset; - return (size_t) ~0; -} -static bool d_rename(const char *from, const char *to) { - (void) from, (void) to; - return false; -} -static bool d_remove(const char *path) { - (void) path; - return false; -} -static bool d_mkdir(const char *path) { - (void) path; - return false; -} - -struct mg_fs mg_fs_dummy = {d_stat, d_list, d_open, d_close, d_read, - d_write, d_seek, d_rename, d_remove, d_mkdir}; diff --git a/src/fs_posix.c b/src/fs_posix.c index feabebfe..968b7a48 100644 --- a/src/fs_posix.c +++ b/src/fs_posix.c @@ -202,6 +202,47 @@ static bool p_mkdir(const char *path) { return mkdir(path, 0775) == 0; } +#else + +static int p_stat(const char *path, size_t *size, time_t *mtime) { + (void) path, (void) size, (void) mtime; + return 0; +} +static void p_list(const char *path, void (*fn)(const char *, void *), + void *userdata) { + (void) path, (void) fn, (void) userdata; +} +static void *p_open(const char *path, int flags) { + (void) path, (void) flags; + return NULL; +} +static void p_close(void *fp) { + (void) fp; +} +static size_t p_read(void *fd, void *buf, size_t len) { + (void) fd, (void) buf, (void) len; + return 0; +} +static size_t p_write(void *fd, const void *buf, size_t len) { + (void) fd, (void) buf, (void) len; + return 0; +} +static size_t p_seek(void *fd, size_t offset) { + (void) fd, (void) offset; + return (size_t) ~0; +} +static bool p_rename(const char *from, const char *to) { + (void) from, (void) to; + return false; +} +static bool p_remove(const char *path) { + (void) path; + return false; +} +static bool p_mkdir(const char *path) { + (void) path; + return false; +} #endif struct mg_fs mg_fs_posix = {p_stat, p_list, p_open, p_close, p_read,