Add "GetFileInfoByHandle" function to (many) file systems

This commit is contained in:
Henrik Rydgård
2025-03-19 10:42:30 +01:00
parent c4241e283a
commit ef386ac4c5
11 changed files with 58 additions and 3 deletions
+17
View File
@@ -638,6 +638,23 @@ PSPFileInfo ISOFileSystem::GetFileInfo(std::string filename) {
return x;
}
PSPFileInfo ISOFileSystem::GetFileInfoByHandle(u32 handle) {
auto iter = entries.find(handle);
PSPFileInfo x;
if (iter != entries.end()) {
const TreeEntry *entry = iter->second.file;
x.name = entry->name;
// Strangely, it seems to be executable even for files.
x.access = 0555;
x.size = entry->size;
x.exists = true;
x.type = entry->isDirectory ? FILETYPE_DIRECTORY : FILETYPE_NORMAL;
x.isOnSectorSystem = true;
x.startSector = entry->startingPosition / 2048;
}
return x;
}
std::vector<PSPFileInfo> ISOFileSystem::GetDirListing(const std::string &path, bool *exists) {
std::vector<PSPFileInfo> myVector;
TreeEntry *entry = GetFromPath(path);