From 595dc42dcb03949164014fe52ceaa69dfba4b51e Mon Sep 17 00:00:00 2001 From: "fires.gc" Date: Tue, 24 Feb 2009 07:18:08 +0000 Subject: [PATCH] added check if "file open dialog" changes the working directory. i dunno why but some times the file open dialog changes my working directory... the code is for further investigations git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2408 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/FileUtil.cpp | 6 ++++++ Source/Core/Common/Src/FileUtil.h | 1 + Source/Core/DolphinWX/Src/FrameTools.cpp | 13 +++++++++++++ 3 files changed, 20 insertions(+) diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 0edb09e330..e371ab78e5 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -547,4 +547,10 @@ void GetCurrentDirectory(std::string& _rDirectory) _rDirectory = getcwd(tmpBuffer, MAX_PATH); } +bool SetCurrentDirectory(const std::string& _rDirectory) +{ + return chdir(_rDirectory.c_str()) == 0; +} + + } // namespace diff --git a/Source/Core/Common/Src/FileUtil.h b/Source/Core/Common/Src/FileUtil.h index 10bf33e3bc..fd3816eaf4 100644 --- a/Source/Core/Common/Src/FileUtil.h +++ b/Source/Core/Common/Src/FileUtil.h @@ -55,6 +55,7 @@ u32 ScanDirectoryTree(const std::string& _Directory, FSTEntry& parentEntry); bool DeleteDirRecursively(const std::string& _Directory); void GetCurrentDirectory(std::string& _rDirectory); +bool SetCurrentDirectory(const std::string& _rDirectory); } // namespace diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 5b74242f6b..93cfb97ac6 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -407,6 +407,9 @@ void CFrame::OnOpen(wxCommandEvent& WXUNUSED (event)) void CFrame::DoOpen(bool Boot) { + std::string currentDir; + File::GetCurrentDirectory(currentDir); + wxString path = wxFileSelector( _T("Select the file to load"), wxEmptyString, wxEmptyString, wxEmptyString, @@ -423,6 +426,16 @@ void CFrame::DoOpen(bool Boot) return; } + std::string currentDir2; + File::GetCurrentDirectory(currentDir2); + + if (currentDir != currentDir2) + { + PanicAlert("Current dir changed has been changeg from %s to %s after wxFileSelector!",currentDir.c_str(),currentDir2.c_str()); + File::SetCurrentDirectory(currentDir); + } + + // Should we boot a new game or just change the disc? if(Boot) {