summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2013-09-11 03:53:36 +0200
committerPierre Bourdon <delroth@gmail.com>2013-09-14 06:08:29 +0200
commitb587af3ea3cd0df8c6f0c31ae8d8c4bf39b15316 (patch)
tree2ab59f14cdd5064df20f05d876f0373e51c2b81d /Source/Core
parentdfcef6890efe6537c0229ac4aacc472f1ce89dbd (diff)
Change the initial user directory creation to stop special casing Windows
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/Src/CommonPaths.h1
-rw-r--r--Source/Core/Common/Src/FileUtil.cpp30
-rw-r--r--Source/Core/DolphinWX/Src/Main.cpp8
3 files changed, 25 insertions, 14 deletions
diff --git a/Source/Core/Common/Src/CommonPaths.h b/Source/Core/Common/Src/CommonPaths.h
index 38640723e5..fd5ca2b238 100644
--- a/Source/Core/Common/Src/CommonPaths.h
+++ b/Source/Core/Common/Src/CommonPaths.h
@@ -38,6 +38,7 @@
// Shared data dirs (Sys and shared User for linux)
#ifdef _WIN32
#define SYSDATA_DIR "Sys"
+ #define SHARED_USER_DIR File::GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP
#elif defined __APPLE__
#define SYSDATA_DIR "Contents/Resources/Sys"
#define SHARED_USER_DIR File::GetBundleDirectory() + \
diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp
index d2be401fb1..92e9674ff2 100644
--- a/Source/Core/Common/Src/FileUtil.cpp
+++ b/Source/Core/Common/Src/FileUtil.cpp
@@ -551,11 +551,24 @@ bool DeleteDirRecursively(const std::string &directory)
// Create directory and copy contents (does not overwrite existing files)
void CopyDir(const std::string &source_path, const std::string &dest_path)
{
-#ifndef _WIN32
if (source_path == dest_path) return;
if (!File::Exists(source_path)) return;
if (!File::Exists(dest_path)) File::CreateFullPath(dest_path);
+#ifdef _WIN32
+ WIN32_FIND_DATA ffd;
+ HANDLE hFind = FindFirstFile(UTF8ToTStr(source_path + "\\*").c_str(), &ffd);
+
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ FindClose(hFind);
+ return;
+ }
+
+ do
+ {
+ const std::string virtualName(TStrToUTF8(ffd.cFileName));
+#else
struct dirent dirent, *result = NULL;
DIR *dirp = opendir(source_path.c_str());
if (!dirp) return;
@@ -563,10 +576,9 @@ void CopyDir(const std::string &source_path, const std::string &dest_path)
while (!readdir_r(dirp, &dirent, &result) && result)
{
const std::string virtualName(result->d_name);
+#endif
// check for "." and ".."
- if (((virtualName[0] == '.') && (virtualName[1] == '\0')) ||
- ((virtualName[0] == '.') && (virtualName[1] == '.') &&
- (virtualName[2] == '\0')))
+ if (virtualName == "." || virtualName == "..")
continue;
std::string source, dest;
@@ -580,6 +592,10 @@ void CopyDir(const std::string &source_path, const std::string &dest_path)
CopyDir(source, dest);
}
else if (!File::Exists(dest)) File::Copy(source, dest);
+#ifdef _WIN32
+ } while (FindNextFile(hFind, &ffd) != 0);
+ FindClose(hFind);
+#else
}
closedir(dirp);
#endif
@@ -643,9 +659,9 @@ std::string GetSysDirectory()
std::string sysDir;
#if defined (__APPLE__)
- sysDir = GetBundleDirectory();
- sysDir += DIR_SEP;
- sysDir += SYSDATA_DIR;
+ sysDir = GetBundleDirectory() + DIR_SEP + SYSDATA_DIR;
+#elif defined (_WIN32)
+ sysDir = GetExeDirectory() + DIR_SEP + SYSDATA_DIR;
#else
sysDir = SYSDATA_DIR;
#endif
diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp
index 6e55ec1501..9bff5de2d2 100644
--- a/Source/Core/DolphinWX/Src/Main.cpp
+++ b/Source/Core/DolphinWX/Src/Main.cpp
@@ -249,12 +249,6 @@ bool DolphinApp::OnInit()
}
#endif
-#ifdef _WIN32
- if (!wxSetWorkingDirectory(StrToWxStr(File::GetExeDirectory())))
- {
- INFO_LOG(CONSOLE, "Set working directory failed");
- }
-#else
//create all necessary directories in user directory
//TODO : detect the revision and upgrade where necessary
File::CopyDir(std::string(SHARED_USER_DIR GAMECONFIG_DIR DIR_SEP),
@@ -267,7 +261,7 @@ bool DolphinApp::OnInit()
File::GetUserPath(D_WIIUSER_IDX));
File::CopyDir(std::string(SHARED_USER_DIR OPENCL_DIR DIR_SEP),
File::GetUserPath(D_OPENCL_IDX));
-#endif
+
File::CreateFullPath(File::GetUserPath(D_USER_IDX));
File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX));
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX));