mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 21:39:52 +00:00
Merge pull request #7952 from KentuckyCompass/isofilesystem_map
Make ISO filesystem case sensitive and add a few optimizations
This commit is contained in:
commit
96c4fecccc
@ -262,7 +262,7 @@ void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root,
|
||||
}
|
||||
else
|
||||
{
|
||||
e->name = std::string((char *)&dir.firstIdChar, dir.identifierLength);
|
||||
e->name = std::string((const char *)&dir.firstIdChar, dir.identifierLength);
|
||||
relative = false;
|
||||
}
|
||||
|
||||
@ -298,41 +298,45 @@ void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root,
|
||||
}
|
||||
}
|
||||
|
||||
ISOFileSystem::TreeEntry *ISOFileSystem::GetFromPath(std::string path, bool catchError)
|
||||
ISOFileSystem::TreeEntry *ISOFileSystem::GetFromPath(const std::string &path, bool catchError)
|
||||
{
|
||||
if (path.length() == 0) {
|
||||
const size_t pathLength = path.length();
|
||||
|
||||
if (pathLength == 0) {
|
||||
// Ah, the device! "umd0:"
|
||||
return &entireISO;
|
||||
}
|
||||
|
||||
if (path.substr(0,2) == "./")
|
||||
path.erase(0,2);
|
||||
size_t pathIndex = 0;
|
||||
|
||||
if (path[0] == '/')
|
||||
path.erase(0,1);
|
||||
// Skip "./"
|
||||
if (pathLength > pathIndex + 1 && path[pathIndex] == '.' && path[pathIndex + 1] == '/')
|
||||
pathIndex += 2;
|
||||
|
||||
// Skip "/"
|
||||
if (pathLength > pathIndex && path[pathIndex] == '/')
|
||||
++pathIndex;
|
||||
|
||||
if (pathLength <= pathIndex)
|
||||
return treeroot;
|
||||
|
||||
TreeEntry *e = treeroot;
|
||||
if (path.length() == 0)
|
||||
return e;
|
||||
|
||||
while (true)
|
||||
{
|
||||
TreeEntry *ne = 0;
|
||||
TreeEntry *ne = nullptr;
|
||||
std::string name = "";
|
||||
if (path.length()>0)
|
||||
if (pathLength > pathIndex)
|
||||
{
|
||||
size_t nextSlashIndex = path.find_first_of('/', pathIndex);
|
||||
if (nextSlashIndex == std::string::npos)
|
||||
nextSlashIndex = pathLength;
|
||||
|
||||
const std::string firstPathComponent = path.substr(pathIndex, nextSlashIndex - pathIndex);
|
||||
for (size_t i = 0; i < e->children.size(); i++)
|
||||
{
|
||||
std::string n = (e->children[i]->name);
|
||||
for (size_t j = 0; j < n.size(); j++) {
|
||||
n[j] = tolower(n[j]);
|
||||
}
|
||||
std::string curPath = path.substr(0, path.find_first_of('/'));
|
||||
for (size_t j = 0; j < curPath.size(); j++) {
|
||||
curPath[j] = tolower(curPath[j]);
|
||||
}
|
||||
const std::string &n = e->children[i]->name;
|
||||
|
||||
if (curPath == n)
|
||||
if (firstPathComponent == n)
|
||||
{
|
||||
//yay we got it
|
||||
ne = e->children[i];
|
||||
@ -341,23 +345,22 @@ ISOFileSystem::TreeEntry *ISOFileSystem::GetFromPath(std::string path, bool catc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ne)
|
||||
{
|
||||
e = ne;
|
||||
size_t l = name.length();
|
||||
path.erase(0, l);
|
||||
if (path.length() == 0 || (path.length()==1 && path[0] == '/'))
|
||||
pathIndex += name.length();
|
||||
if (pathIndex < pathLength && path[pathIndex] == '/')
|
||||
++pathIndex;
|
||||
|
||||
if (pathLength <= pathIndex)
|
||||
return e;
|
||||
path.erase(0, 1);
|
||||
while (path[0] == '/')
|
||||
path.erase(0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (catchError)
|
||||
{
|
||||
ERROR_LOG(FILESYS,"File %s not found", path.c_str());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -697,15 +700,17 @@ std::vector<PSPFileInfo> ISOFileSystem::GetDirListing(std::string path)
|
||||
std::vector<PSPFileInfo> myVector;
|
||||
TreeEntry *entry = GetFromPath(path);
|
||||
if (! entry)
|
||||
{
|
||||
return myVector;
|
||||
}
|
||||
|
||||
const std::string dot(".");
|
||||
const std::string dotdot("..");
|
||||
|
||||
for (size_t i = 0; i < entry->children.size(); i++)
|
||||
{
|
||||
TreeEntry *e = entry->children[i];
|
||||
|
||||
if(!strcmp(e->name.c_str(), ".") || !strcmp(e->name.c_str(), "..")) // do not include the relative entries in the list
|
||||
// do not include the relative entries in the list
|
||||
if (e->name == dot || e->name == dotdot)
|
||||
continue;
|
||||
|
||||
PSPFileInfo x;
|
||||
|
@ -91,7 +91,7 @@ private:
|
||||
std::vector<std::string> restrictTree;
|
||||
|
||||
void ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root, size_t level);
|
||||
TreeEntry *GetFromPath(std::string path, bool catchError = true);
|
||||
TreeEntry *GetFromPath(const std::string &path, bool catchError = true);
|
||||
std::string EntryFullPath(TreeEntry *e);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user