From df6cc66d87ef215f898d3fffc0b6914d3caac78e Mon Sep 17 00:00:00 2001 From: "fires.gc" Date: Mon, 1 Dec 2008 06:46:50 +0000 Subject: [PATCH] added GetCurrentDirectory function some times "something" changes the current directory if you open a file with the file browser dialog... i need this function to investigate the problem :) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1357 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/FileUtil.cpp | 19 ++++++++++++++++--- Source/Core/Common/Src/FileUtil.h | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index d892ae4d7a..5c43d22567 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -20,10 +20,11 @@ #ifdef _WIN32 #include -#include // for SHGetFolderPath +#include // for SHGetFolderPath #include -#include // for GetSaveFileName +#include // for GetSaveFileName #include +#include // getcwd #else #include #include @@ -224,7 +225,7 @@ bool Rename(const char *srcFilename, const char *destFilename) bool Copy(const char *srcFilename, const char *destFilename) { #ifdef _WIN32 - return CopyFile(srcFilename, destFilename, FALSE); + return (CopyFile(srcFilename, destFilename, FALSE) == TRUE) ? true : false; #else #define BSIZE 1024 @@ -478,4 +479,16 @@ error_jmp: #endif } +void GetCurrentDirectory(std::string& _rDirectory) +{ +#ifdef _WIN32 + + char tmpBuffer[MAX_PATH+1]; + getcwd(tmpBuffer, MAX_PATH); + _rDirectory = tmpBuffer; +#else + PanicAlert("Missing Linux support of GetCurrentDirectory"); +#endif +} + } // namespace diff --git a/Source/Core/Common/Src/FileUtil.h b/Source/Core/Common/Src/FileUtil.h index 610531ce16..9a0ef8ffbf 100644 --- a/Source/Core/Common/Src/FileUtil.h +++ b/Source/Core/Common/Src/FileUtil.h @@ -53,6 +53,7 @@ bool CreateEmptyFile(const char *filename); u32 ScanDirectoryTree(const std::string& _Directory, FSTEntry& parentEntry); bool DeleteDirRecursively(const std::string& _Directory); +void GetCurrentDirectory(std::string& _rDirectory); } // namespace