Change the initial user directory creation to stop special casing Windows
This commit is contained in:
parent
dfcef6890e
commit
b587af3ea3
|
@ -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() + \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue