Support additional prefixes, like memstick:.

I also found umd01: and host01: work, etc.  May help #5377 and possibly
others.

It seems like games can assign these at will and potentially even
subpaths, but reporting hasn't shown many cases yet.  We can still watch
it.

Avoided mapping additional systems because savestates don't handle that
well currently.
This commit is contained in:
Unknown W. Brackets 2014-02-10 01:41:28 -08:00
parent 2f3075e75e
commit 73722d9cee
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) )
{
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++)
{
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);
*system = &(fileSystems[i]);
@ -239,6 +244,20 @@ bool MetaFileSystem::MapFilePath(const std::string &_inpath, std::string &outpat
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)
{
lock_guard guard(lock);
@ -267,7 +286,7 @@ void MetaFileSystem::Remount(IFileSystem *oldSystem, IFileSystem *newSystem) {
IFileSystem *MetaFileSystem::GetSystem(const std::string &prefix) {
for (auto it = fileSystems.begin(); it != fileSystems.end(); ++it) {
if (it->prefix == prefix)
if (it->prefix == NormalizePrefix(prefix))
return it->system;
}
return NULL;