mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-25 08:14:45 +02:00
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:
@@ -631,11 +631,14 @@ PSPFileInfo ISOFileSystem::GetFileInfo(std::string filename) {
|
||||
return x;
|
||||
}
|
||||
|
||||
std::vector<PSPFileInfo> ISOFileSystem::GetDirListing(std::string path) {
|
||||
std::vector<PSPFileInfo> ISOFileSystem::GetDirListing(const std::string &path, bool *exists) {
|
||||
std::vector<PSPFileInfo> myVector;
|
||||
TreeEntry *entry = GetFromPath(path);
|
||||
if (!entry)
|
||||
if (!entry) {
|
||||
if (exists)
|
||||
*exists = false;
|
||||
return myVector;
|
||||
}
|
||||
|
||||
const std::string dot(".");
|
||||
const std::string dotdot("..");
|
||||
@@ -651,6 +654,7 @@ std::vector<PSPFileInfo> ISOFileSystem::GetDirListing(std::string path) {
|
||||
x.name = e->name;
|
||||
// Strangely, it seems to be executable even for files.
|
||||
x.access = 0555;
|
||||
x.exists = true;
|
||||
x.size = e->size;
|
||||
x.type = e->isDirectory ? FILETYPE_DIRECTORY : FILETYPE_NORMAL;
|
||||
x.isOnSectorSystem = true;
|
||||
@@ -659,6 +663,8 @@ std::vector<PSPFileInfo> ISOFileSystem::GetDirListing(std::string path) {
|
||||
x.numSectors = (u32)((e->size + sectorSize - 1) / sectorSize);
|
||||
myVector.push_back(x);
|
||||
}
|
||||
if (exists)
|
||||
*exists = true;
|
||||
return myVector;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user