Io: Provide directory existence with listing.

Sometimes, you need to tell the difference between an empty directory and
one that doesn't exist at all.  We can do this in a single call.
This commit is contained in:
Unknown W. Brackets
2022-10-09 14:42:31 -07:00
parent 7b8350f8a8
commit 4942692558
11 changed files with 66 additions and 29 deletions
+6 -8
View File
@@ -369,19 +369,17 @@ PSPFileInfo MetaFileSystem::GetFileInfo(std::string filename)
}
}
std::vector<PSPFileInfo> MetaFileSystem::GetDirListing(std::string path)
{
std::vector<PSPFileInfo> MetaFileSystem::GetDirListing(const std::string &path, bool *exists) {
std::lock_guard<std::recursive_mutex> guard(lock);
std::string of;
IFileSystem *system;
int error = MapFilePath(path, of, &system);
if (error == 0)
{
return system->GetDirListing(of);
}
else
{
if (error == 0) {
return system->GetDirListing(of, exists);
} else {
std::vector<PSPFileInfo> empty;
if (exists)
*exists = false;
return empty;
}
}