diff --git a/src/DSi_NAND.cpp b/src/DSi_NAND.cpp index 6b766263..7cb355dd 100644 --- a/src/DSi_NAND.cpp +++ b/src/DSi_NAND.cpp @@ -567,8 +567,8 @@ void debug_listfiles(const char* path) for (;;) { res = f_readdir(&dir, &info); - if (res != FR_OK) return; - if (!info.fname[0]) return; + if (res != FR_OK) break; + if (!info.fname[0]) break; char fullname[512]; sprintf(fullname, "%s/%s", path, info.fname); diff --git a/src/FATStorage.cpp b/src/FATStorage.cpp index 939d2a05..7e285ad0 100644 --- a/src/FATStorage.cpp +++ b/src/FATStorage.cpp @@ -171,7 +171,7 @@ int FATStorage::CleanupDirectory(std::string path, int level) FILINFO info; FRESULT res; - res = f_opendir(&dir, path); + res = f_opendir(&dir, path.c_str()); if (res != FR_OK) return 0; std::vector deletelist; @@ -181,8 +181,8 @@ int FATStorage::CleanupDirectory(std::string path, int level) for (;;) { res = f_readdir(&dir, &info); - if (res != FR_OK) return; - if (!info.fname[0]) return; + if (res != FR_OK) break; + if (!info.fname[0]) break; std::string fullpath = path + info.fname; @@ -307,12 +307,30 @@ bool FATStorage::BuildSubdirectory(const char* sourcedir, const char* path, int auto lastmodified = entry.last_write_time(); s64 lastmodified_raw = std::chrono::duration_cast(lastmodified.time_since_epoch()).count(); - IndexEntry derpo; - derpo.Path = entry.path().string(); - derpo.Size = filesize; - derpo.LastModified = lastmodified_raw; + bool import = false; + if (Index.count(innerpath) < 1) + { + import = true; + } + else + { + IndexEntry& chk = Index[innerpath]; + if (chk.Size != filesize) import = true; + if (chk.LastModified != lastmodified_raw) import = true; + } - Index[derpo.Path] = derpo; + if (import) + { + IndexEntry entry; + entry.Path = innerpath; + entry.Size = filesize; + entry.LastModified = lastmodified_raw; + + Index[entry.Path] = entry; + + innerpath = "0:/" + innerpath; + // import! + } } }