mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add a way to restrict ISO reading to a single path.
This is for GameInfoCache.
This commit is contained in:
parent
20bb55e1cb
commit
d11a5debcb
3 changed files with 32 additions and 8 deletions
|
@ -133,8 +133,21 @@ struct VolDescriptor
|
||||||
|
|
||||||
std::list<ISOFileSystem::TreeEntry *> ISOFileSystem::entryFreeList;
|
std::list<ISOFileSystem::TreeEntry *> ISOFileSystem::entryFreeList;
|
||||||
|
|
||||||
ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevice)
|
ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevice, std::string _restrictPath)
|
||||||
{
|
{
|
||||||
|
if (!_restrictPath.empty())
|
||||||
|
{
|
||||||
|
size_t pos = _restrictPath.find_first_not_of('/');
|
||||||
|
while (!_restrictPath.empty())
|
||||||
|
{
|
||||||
|
size_t endPos = _restrictPath.find_first_of('/', pos);
|
||||||
|
if (pos != endPos)
|
||||||
|
restrictTree.push_back(_restrictPath.substr(pos, endPos));
|
||||||
|
pos = _restrictPath.find_first_not_of('/', endPos);
|
||||||
|
_restrictPath.erase(0, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
blockDevice = _blockDevice;
|
blockDevice = _blockDevice;
|
||||||
hAlloc = _hAlloc;
|
hAlloc = _hAlloc;
|
||||||
|
|
||||||
|
@ -169,7 +182,7 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevic
|
||||||
u32 rootSector = desc.root.firstDataSectorLE;
|
u32 rootSector = desc.root.firstDataSectorLE;
|
||||||
u32 rootSize = desc.root.dataLengthLE;
|
u32 rootSize = desc.root.dataLengthLE;
|
||||||
|
|
||||||
ReadDirectory(rootSector, rootSize, treeroot);
|
ReadDirectory(rootSector, rootSize, treeroot, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ISOFileSystem::~ISOFileSystem()
|
ISOFileSystem::~ISOFileSystem()
|
||||||
|
@ -178,7 +191,7 @@ ISOFileSystem::~ISOFileSystem()
|
||||||
ReleaseTreeEntry(treeroot);
|
ReleaseTreeEntry(treeroot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root)
|
void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root, size_t level)
|
||||||
{
|
{
|
||||||
for (u32 secnum = startsector, endsector = dirsize/2048 + startsector; secnum < endsector; ++secnum)
|
for (u32 secnum = startsector, endsector = dirsize/2048 + startsector; secnum < endsector; ++secnum)
|
||||||
{
|
{
|
||||||
|
@ -198,7 +211,7 @@ void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root)
|
||||||
if (offset + IDENTIFIER_OFFSET + dir.identifierLength > 2048)
|
if (offset + IDENTIFIER_OFFSET + dir.identifierLength > 2048)
|
||||||
{
|
{
|
||||||
ERROR_LOG(FILESYS, "Directory entry crosses sectors, corrupt iso?");
|
ERROR_LOG(FILESYS, "Directory entry crosses sectors, corrupt iso?");
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += dir.size;
|
offset += dir.size;
|
||||||
|
@ -241,7 +254,14 @@ void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ReadDirectory(dir.firstDataSectorLE, dir.dataLengthLE, e);
|
bool doRecurse = true;
|
||||||
|
if (!restrictTree.empty())
|
||||||
|
doRecurse = level < restrictTree.size() && restrictTree[level] == e->name;
|
||||||
|
|
||||||
|
if (doRecurse)
|
||||||
|
ReadDirectory(dir.firstDataSectorLE, dir.dataLengthLE, e, level + 1);
|
||||||
|
else
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
root->children.push_back(e);
|
root->children.push_back(e);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@
|
||||||
class ISOFileSystem : public IFileSystem
|
class ISOFileSystem : public IFileSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevice);
|
ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevice, std::string _restrictPath = "");
|
||||||
~ISOFileSystem();
|
~ISOFileSystem();
|
||||||
void DoState(PointerWrap &p);
|
void DoState(PointerWrap &p);
|
||||||
std::vector<PSPFileInfo> GetDirListing(std::string path);
|
std::vector<PSPFileInfo> GetDirListing(std::string path);
|
||||||
|
@ -87,7 +88,10 @@ private:
|
||||||
|
|
||||||
TreeEntry entireISO;
|
TreeEntry entireISO;
|
||||||
|
|
||||||
void ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root);
|
// Don't use this in the emu, not savestated.
|
||||||
|
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(std::string path, bool catchError=true);
|
||||||
std::string EntryFullPath(TreeEntry *e);
|
std::string EntryFullPath(TreeEntry *e);
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ again:
|
||||||
BlockDevice *bd = constructBlockDevice(gamePath.c_str());
|
BlockDevice *bd = constructBlockDevice(gamePath.c_str());
|
||||||
if (!bd)
|
if (!bd)
|
||||||
return 0; // nothing to do here..
|
return 0; // nothing to do here..
|
||||||
ISOFileSystem umd(&handles, bd);
|
ISOFileSystem umd(&handles, bd, "/PSP_GAME");
|
||||||
|
|
||||||
GameInfo *info = new GameInfo();
|
GameInfo *info = new GameInfo();
|
||||||
info->wantBG = wantBG;
|
info->wantBG = wantBG;
|
||||||
|
|
Loading…
Add table
Reference in a new issue