summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/FileUtil.cpp
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/Common/Src/FileUtil.cpp
parentdfcef6890efe6537c0229ac4aacc472f1ce89dbd (diff)
Change the initial user directory creation to stop special casing Windows
Diffstat (limited to 'Source/Core/Common/Src/FileUtil.cpp')
-rw-r--r--Source/Core/Common/Src/FileUtil.cpp30
1 files changed, 23 insertions, 7 deletions
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