mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-26 15:50:00 -06:00
fix more bugs
This commit is contained in:
@ -611,14 +611,14 @@ bool FATStorage::DeleteDirectory(std::string path, int level)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FATStorage::CleanupDirectory(std::string path, int level)
|
void FATStorage::CleanupDirectory(std::string sourcedir, std::string path, int level)
|
||||||
{
|
{
|
||||||
if (level >= 32) return;
|
if (level >= 32) return;
|
||||||
|
|
||||||
fDIR dir;
|
fDIR dir;
|
||||||
FILINFO info;
|
FILINFO info;
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
|
printf("CLEANING UP DIRECTORY %s (level=%d)\n", path.c_str(), level);
|
||||||
std::string fullpath = "0:/" + path;
|
std::string fullpath = "0:/" + path;
|
||||||
res = f_opendir(&dir, fullpath.c_str());
|
res = f_opendir(&dir, fullpath.c_str());
|
||||||
if (res != FR_OK) return;
|
if (res != FR_OK) return;
|
||||||
@ -634,11 +634,18 @@ void FATStorage::CleanupDirectory(std::string path, int level)
|
|||||||
if (!info.fname[0]) break;
|
if (!info.fname[0]) break;
|
||||||
|
|
||||||
std::string fullpath = path + info.fname;
|
std::string fullpath = path + info.fname;
|
||||||
|
printf("FOUND ENTRY %s %08X (%d/%d, %d)\n",
|
||||||
|
fullpath.c_str(), info.fattrib, FileIndex.count(fullpath), DirIndex.count(fullpath),
|
||||||
|
fs::exists(sourcedir+"/"+fullpath));
|
||||||
if (info.fattrib & AM_DIR)
|
if (info.fattrib & AM_DIR)
|
||||||
{
|
{
|
||||||
if (DirIndex.count(fullpath) < 1)
|
if (DirIndex.count(fullpath) < 1)
|
||||||
dirdeletelist.push_back(fullpath);
|
dirdeletelist.push_back(fullpath);
|
||||||
|
else if (!fs::is_directory(sourcedir+"/"+fullpath))
|
||||||
|
{
|
||||||
|
DirIndex.erase(fullpath);
|
||||||
|
dirdeletelist.push_back(fullpath);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
subdirlist.push_back(fullpath);
|
subdirlist.push_back(fullpath);
|
||||||
}
|
}
|
||||||
@ -646,6 +653,11 @@ void FATStorage::CleanupDirectory(std::string path, int level)
|
|||||||
{
|
{
|
||||||
if (FileIndex.count(fullpath) < 1)
|
if (FileIndex.count(fullpath) < 1)
|
||||||
filedeletelist.push_back(fullpath);
|
filedeletelist.push_back(fullpath);
|
||||||
|
else if (!fs::is_regular_file(sourcedir+"/"+fullpath))
|
||||||
|
{
|
||||||
|
FileIndex.erase(fullpath);
|
||||||
|
filedeletelist.push_back(fullpath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,7 +677,7 @@ void FATStorage::CleanupDirectory(std::string path, int level)
|
|||||||
|
|
||||||
for (auto& entry : subdirlist)
|
for (auto& entry : subdirlist)
|
||||||
{
|
{
|
||||||
CleanupDirectory(entry+"/", level+1);
|
CleanupDirectory(sourcedir, entry+"/", level+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,7 +739,7 @@ bool FATStorage::BuildSubdirectory(const char* sourcedir, const char* path, int
|
|||||||
if (level == 0)
|
if (level == 0)
|
||||||
{
|
{
|
||||||
// remove whatever isn't in the index
|
// remove whatever isn't in the index
|
||||||
CleanupDirectory("", 0);
|
CleanupDirectory(sourcedir, "", 0);
|
||||||
|
|
||||||
int srclen = strlen(sourcedir);
|
int srclen = strlen(sourcedir);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ private:
|
|||||||
|
|
||||||
bool CanFitFile(u32 len);
|
bool CanFitFile(u32 len);
|
||||||
bool DeleteDirectory(std::string path, int level);
|
bool DeleteDirectory(std::string path, int level);
|
||||||
void CleanupDirectory(std::string path, int level);
|
void CleanupDirectory(std::string sourcedir, std::string path, int level);
|
||||||
bool ImportFile(std::string path, std::string in);
|
bool ImportFile(std::string path, std::string in);
|
||||||
bool BuildSubdirectory(const char* sourcedir, const char* path, int level);
|
bool BuildSubdirectory(const char* sourcedir, const char* path, int level);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user