GameCubeConfig: If the user selects a memcard file path within Dolphin's directory, store the path relative to it.
This makes Dolphin more portable in portable mode, since the memory card file is still found if the directory is moved somewhere else. This also means that we have to explicitly compare absolute paths if we want to check for both slots containing the same file.
This commit is contained in:
parent
df70f50fdf
commit
583e3fd9e0
|
@ -8,6 +8,7 @@
|
||||||
#include <wx/checkbox.h>
|
#include <wx/checkbox.h>
|
||||||
#include <wx/choice.h>
|
#include <wx/choice.h>
|
||||||
#include <wx/filedlg.h>
|
#include <wx/filedlg.h>
|
||||||
|
#include <wx/filename.h>
|
||||||
#include <wx/gbsizer.h>
|
#include <wx/gbsizer.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
#include <wx/stattext.h>
|
#include <wx/stattext.h>
|
||||||
|
@ -332,22 +333,21 @@ void GameCubeConfigPane::ChooseSlotPath(bool is_slot_a, TEXIDevices device_type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (!strncmp(File::GetExeDirectory().c_str(), filename.c_str(), File::GetExeDirectory().size()))
|
// If the Memory Card file is within the Exe dir, we can assume that the user wants it to be stored relative
|
||||||
{
|
// to the executable, so it stays set correctly when the probably portable Exe dir is moved.
|
||||||
// If the Exe Directory Matches the prefix of the filename, we still need to verify
|
std::string exeDir = File::GetExeDirectory() + '\\';
|
||||||
// that the next character is a directory separator character, otherwise we may create an invalid path
|
if (!strncmp(exeDir.c_str(), filename.c_str(), exeDir.size()))
|
||||||
char next_char = filename.at(File::GetExeDirectory().size()) + 1;
|
filename.erase(0, exeDir.size());
|
||||||
if (next_char == '/' || next_char == '\\')
|
|
||||||
{
|
|
||||||
filename.erase(0, File::GetExeDirectory().size() + 1);
|
|
||||||
filename = "./" + filename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::replace(filename.begin(), filename.end(), '\\', '/');
|
std::replace(filename.begin(), filename.end(), '\\', '/');
|
||||||
#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...
|
||||||
if (filename.compare(is_slot_a ? pathB : pathA) != 0)
|
wxFileName newFilename(filename);
|
||||||
|
wxFileName otherFilename(is_slot_a ? pathB : pathA);
|
||||||
|
newFilename.MakeAbsolute();
|
||||||
|
otherFilename.MakeAbsolute();
|
||||||
|
if (newFilename.GetFullPath().compare(otherFilename.GetFullPath()) != 0)
|
||||||
{
|
{
|
||||||
if (memcard)
|
if (memcard)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue