mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-21 19:51:50 +00:00
Add FS API layer
This commit is contained in:
1 parent
b98556a4dc
commit
9346122c29
10 files changed
+660
-309
No files matched your search
@@ -2,11 +2,25 @@
|
||||
|
||||
#include "arch.h"
|
||||
|
||||
FILE *mg_fopen_packed(const char *path, const char *mode);
|
||||
enum { MG_FS_READ = 1, MG_FS_WRITE = 2, MG_FS_DIR = 4 };
|
||||
|
||||
#if (defined(__linux__) && defined(__GNUC__)) || defined(__NEWLIB__)
|
||||
#define MG_ENABLE_PACKED_FS 1
|
||||
#define MG_FOPENCOOKIE
|
||||
#else
|
||||
#define MG_ENABLE_PACKED_FS 0
|
||||
#endif
|
||||
// Filesystem API functions
|
||||
struct mg_fs {
|
||||
char *(*realpath)(const char *path, char *resolved_path);
|
||||
int (*stat)(const char *path, size_t *size, unsigned *mtime);
|
||||
void (*list)(const char *path, void (*fn)(const char *, void *), void *);
|
||||
struct mg_fd *(*open)(const char *path, int flags);
|
||||
void (*close)(struct mg_fd *fd);
|
||||
size_t (*read)(void *fd, void *buf, size_t len);
|
||||
size_t (*write)(void *fd, const void *buf, size_t len);
|
||||
size_t (*seek)(void *fd, size_t offset);
|
||||
};
|
||||
|
||||
// File descriptor
|
||||
struct mg_fd {
|
||||
void *fd;
|
||||
struct mg_fs *fs;
|
||||
};
|
||||
|
||||
extern struct mg_fs mg_fs_posix; // POSIX open/close/read/write/seek
|
||||
extern struct mg_fs mg_fs_packed; // Packed FS, see examples/complete
|
||||
Reference in new issue
Block a user