Merge pull request #5393 from unknownbrackets/io-minor

Support additional prefixes, like memstick:
This commit is contained in:
Henrik Rydgård 2014-02-10 10:49:12 +01:00
commit 32f637f259
3 changed files with 24 additions and 3 deletions

View File

@ -220,10 +220,15 @@ bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpat
if ( RealPath(*currentDirectory, inpath, realpath) ) if ( RealPath(*currentDirectory, inpath, realpath) )
{ {
std::string prefix = realpath;
size_t prefixPos = realpath.find(':');
if (prefixPos != realpath.npos)
prefix = NormalizePrefix(realpath.substr(0, prefixPos + 1));
for (size_t i = 0; i < fileSystems.size(); i++) for (size_t i = 0; i < fileSystems.size(); i++)
{ {
size_t prefLen = fileSystems[i].prefix.size(); size_t prefLen = fileSystems[i].prefix.size();
if (strncasecmp(fileSystems[i].prefix.c_str(), realpath.c_str(), prefLen) == 0) if (strncasecmp(fileSystems[i].prefix.c_str(), prefix.c_str(), prefLen) == 0)
{ {
outpath = realpath.substr(prefLen); outpath = realpath.substr(prefLen);
*system = &(fileSystems[i]); *system = &(fileSystems[i]);
@ -239,6 +244,20 @@ bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpat
return false; return false;
} }
std::string MetaFileSystem::NormalizePrefix(std::string prefix) const {
// Let's apply some mapping here since it won't break savestates.
if (prefix == "memstick:")
prefix = "ms0:";
// Seems like umd00: etc. work just fine...
if (startsWith(prefix, "umd"))
prefix = "umd0:";
// Seems like umd00: etc. work just fine...
if (startsWith(prefix, "host"))
prefix = "host0:";
return prefix;
}
void MetaFileSystem::Mount(std::string prefix, IFileSystem *system) void MetaFileSystem::Mount(std::string prefix, IFileSystem *system)
{ {
lock_guard guard(lock); lock_guard guard(lock);
@ -267,7 +286,7 @@ void MetaFileSystem::Remount(IFileSystem *oldSystem, IFileSystem *newSystem) {
IFileSystem *MetaFileSystem::GetSystem(const std::string &prefix) { IFileSystem *MetaFileSystem::GetSystem(const std::string &prefix) {
for (auto it = fileSystems.begin(); it != fileSystems.end(); ++it) { for (auto it = fileSystems.begin(); it != fileSystems.end(); ++it) {
if (it->prefix == prefix) if (it->prefix == NormalizePrefix(prefix))
return it->system; return it->system;
} }
return NULL; return NULL;

View File

@ -79,6 +79,8 @@ public:
return false; return false;
} }
std::string NormalizePrefix(std::string prefix) const;
// Only possible if a file system is a DirectoryFileSystem or similar. // Only possible if a file system is a DirectoryFileSystem or similar.
bool GetHostPath(const std::string &inpath, std::string &outpath); bool GetHostPath(const std::string &inpath, std::string &outpath);

View File

@ -1338,7 +1338,7 @@ u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 outPtr,
// This should really send it on to a FileSystem implementation instead. // This should really send it on to a FileSystem implementation instead.
if (!strcmp(name, "mscmhc0:") || !strcmp(name, "ms0:")) if (!strcmp(name, "mscmhc0:") || !strcmp(name, "ms0:") || !strcmp(name, "memstick:"))
{ {
// MemorySticks Checks // MemorySticks Checks
switch (cmd) { switch (cmd) {