ChooseMemcardPath bugfix: check for a directory separator before converting an absolute path to a relative path.

if the exe directory and the save directory had the same prefix, .../dolphin emulator/... and .../dolphin/... the path would previously have been incorrectly changed
This commit is contained in:
LPFaint99 2013-10-04 11:31:22 -07:00
parent fe3d0c9aa2
commit 8c103a8dee
1 changed files with 8 additions and 2 deletions

View File

@ -1075,10 +1075,16 @@ void CConfigMain::ChooseMemcardPath(std::string& strMemcard, bool isSlotA)
} }
#ifdef _WIN32 #ifdef _WIN32
if (!strncmp(File::GetExeDirectory().c_str(), filename.c_str(), File::GetExeDirectory().size())) if (!strncmp(File::GetExeDirectory().c_str(), filename.c_str(), File::GetExeDirectory().size()))
{
// If the Exe Directory Matches the prefix of the filename, we still need to verify
// that the next character is a directory separator character, otherwise we may create an invalid path
char next_char = filename.at(File::GetExeDirectory().size())+1;
if (next_char == '/' || next_char == '\\')
{ {
filename.erase(0, File::GetExeDirectory().size() +1); filename.erase(0, File::GetExeDirectory().size() +1);
filename = "./" + filename; filename = "./" + filename;
} }
}
#endif #endif
// also check that the path isn't used for the other memcard... // also check that the path isn't used for the other memcard...