Change in FS API for fs->open() and fs->close()

This commit is contained in:
Sergey Lyubka committed 2022-01-17 14:42:41 +00:00
1 parent c65c8fdaaa
commit f84f3da012
6 files changed
+61 -56

No files matched your search

+4 -8
View File
@@ -57,24 +57,20 @@ static void packed_list(const char *dir, void (*fn)(const char *, void *),
}
}
static struct mg_fd *packed_open(const char *path, int flags) {
static void *packed_open(const char *path, int flags) {
size_t size = 0;
const char *data = mg_unpack(path, &size, NULL);
struct packed_file *fp = NULL;
struct mg_fd *fd = NULL;
if (data == NULL) return NULL;
if (flags & MG_FS_WRITE) return NULL;
fp = (struct packed_file *) calloc(1, sizeof(*fp));
fd = (struct mg_fd *) calloc(1, sizeof(*fd));
fp->size = size;
fp->data = data;
fd->fd = fp;
fd->fs = &mg_fs_packed;
return fd;
return (void *) fp;
}
static void packed_close(struct mg_fd *fd) {
if (fd) free(fd->fd), free(fd);
static void packed_close(void *fp) {
if (fp != NULL) free(fp);
}
static size_t packed_read(void *fd, void *buf, size_t len) {