Windows: Sets the cwd to the folder that dolphin.exe resides in.
Removes the ugliness that was the portable file, and now creating a shortcut or file association is less of a pain it is still necessary to modify the file association from ".../dolphin.exe" "%1" to ".../dolphin.exe" /e "%1" git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7593 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
8244efcc02
commit
1d29204ae6
|
@ -601,6 +601,21 @@ std::string GetBundleDirectory()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::string &GetExeDirectory()
|
||||||
|
{
|
||||||
|
static std::string DolphinPath;
|
||||||
|
if (DolphinPath.empty())
|
||||||
|
{
|
||||||
|
char Dolphin_exe_Path[2048];
|
||||||
|
GetModuleFileNameA(NULL, Dolphin_exe_Path, 2048);
|
||||||
|
DolphinPath = Dolphin_exe_Path;
|
||||||
|
DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\'));
|
||||||
|
}
|
||||||
|
return DolphinPath;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string GetSysDirectory()
|
std::string GetSysDirectory()
|
||||||
{
|
{
|
||||||
std::string sysDir;
|
std::string sysDir;
|
||||||
|
@ -628,6 +643,7 @@ std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath)
|
||||||
if (paths[D_USER_IDX].empty())
|
if (paths[D_USER_IDX].empty())
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
// TODO: use GetExeDirectory() here instead of ROOT_DIR so that if the cwd is changed we still have the correct paths?
|
||||||
paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP;
|
paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP;
|
||||||
#else
|
#else
|
||||||
if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR))
|
if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR))
|
||||||
|
|
|
@ -139,6 +139,10 @@ std::string GetSysDirectory();
|
||||||
std::string GetBundleDirectory();
|
std::string GetBundleDirectory();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::string &GetExeDirectory();
|
||||||
|
#endif
|
||||||
|
|
||||||
bool WriteStringToFile(bool text_file, const std::string &str, const char *filename);
|
bool WriteStringToFile(bool text_file, const std::string &str, const char *filename);
|
||||||
bool ReadFileToString(bool text_file, const char *filename, std::string &str);
|
bool ReadFileToString(bool text_file, const char *filename, std::string &str);
|
||||||
|
|
||||||
|
|
|
@ -200,54 +200,9 @@ bool DolphinApp::OnInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Keep the user config dir free unless user wants to save the working dir
|
if (!wxSetWorkingDirectory(wxString(File::GetExeDirectory().c_str(), *wxConvCurrent)))
|
||||||
if (!File::Exists(File::GetUserPath(D_CONFIG_IDX) + "portable"))
|
|
||||||
{
|
{
|
||||||
char tmp[1024];
|
INFO_LOG(CONSOLE, "set working directory failed");
|
||||||
sprintf(tmp, "%s/.dolphin%swd", (const char*)wxStandardPaths::Get().GetUserConfigDir().mb_str(),
|
|
||||||
#ifdef _M_IX86
|
|
||||||
"x32");
|
|
||||||
#else
|
|
||||||
"x64");
|
|
||||||
#endif
|
|
||||||
std::ifstream workingDir(tmp);
|
|
||||||
if (!workingDir)
|
|
||||||
{
|
|
||||||
if (PanicYesNoT("Dolphin has not been configured with an install location,\nKeep Dolphin portable?"))
|
|
||||||
{
|
|
||||||
std::ofstream portable((File::GetUserPath(D_CONFIG_IDX) + "portable").c_str());
|
|
||||||
if (!portable)
|
|
||||||
{
|
|
||||||
PanicAlertT("Portable Setting could not be saved\n Are you running Dolphin from read only media or from a directory that dolphin is not located in?");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char CWD[1024];
|
|
||||||
sprintf(CWD, "%s", (const char*)wxGetCwd().mb_str());
|
|
||||||
if (PanicYesNoT("Set install location to:\n %s ?", CWD))
|
|
||||||
{
|
|
||||||
std::ofstream workingDirF(tmp);
|
|
||||||
if (!workingDirF)
|
|
||||||
PanicAlertT("Install directory could not be saved");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
workingDirF << CWD << '\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
PanicAlertT("Relaunch Dolphin from the install directory and save from there");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string tmpChar;
|
|
||||||
std::getline(workingDir, tmpChar);
|
|
||||||
if (!wxSetWorkingDirectory(wxString::From8BitData(tmpChar.c_str())))
|
|
||||||
{
|
|
||||||
INFO_LOG(CONSOLE, "set working directory failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
//create all necessary directories in user directory
|
//create all necessary directories in user directory
|
||||||
|
|
Loading…
Reference in New Issue