From a0023469df7d0444d0185320eb29ef087fcd90e7 Mon Sep 17 00:00:00 2001 From: IonutParau Date: Sun, 29 Jun 2025 16:13:18 +0200 Subject: [PATCH] fixed fs shit --- src/components/filesystem.c | 2 +- src/emulator.c | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/filesystem.c b/src/components/filesystem.c index a07158a..b41ac5c 100644 --- a/src/components/filesystem.c +++ b/src/components/filesystem.c @@ -162,7 +162,7 @@ void nn_fs_lastModified(nn_filesystem *fs, void *_, nn_component *component, nn_ return; } - nn_return(computer, nn_values_integer(fs->remove(component, fs->userdata, path))); + nn_return(computer, nn_values_integer(fs->lastModified(component, fs->userdata, path))); nn_fs_readCost(fs, 1, component, computer); } diff --git a/src/emulator.c b/src/emulator.c index 82c58a1..680717a 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -193,6 +193,22 @@ char **ne_fs_list(nn_component *component, ne_fs *fs, const char *path, size_t * return buf; } +size_t ne_fs_size(nn_component *component, ne_fs *fs, const char *path) { + const char *p = ne_fs_diskPath(component, path); + if(p[0] == '/') p++; + + if(DirectoryExists(p)) return 0; + + return GetFileLength(p); +} + +size_t ne_fs_lastModified(nn_component *component, ne_fs *fs, const char *path) { + const char *p = ne_fs_diskPath(component, path); + if(p[0] == '/') p++; + + return GetFileModTime(p); +} + bool ne_fs_isDirectory(nn_component *component, ne_fs *fs, const char *path) { const char *p = ne_fs_diskPath(component, path); if(p[0] == '/') p++; @@ -488,9 +504,9 @@ int main() { .spaceUsed = ne_fs_spaceUsed, .spaceTotal = ne_fs_spaceTotal, .isReadOnly = ne_eeprom_isReadonly, - .size = NULL, + .size = (void *)ne_fs_size, .remove = NULL, - .lastModified = NULL, + .lastModified = (void *)ne_fs_lastModified, .rename = NULL, .exists = (void *)ne_fs_exists, .isDirectory = (void *)ne_fs_isDirectory,