diff options
-rw-r--r-- | src/common/src/common_paths.h | 10 | ||||
-rw-r--r-- | src/common/src/file_util.cpp | 222 | ||||
-rw-r--r-- | src/common/src/file_util.h | 18 |
3 files changed, 118 insertions, 132 deletions
diff --git a/src/common/src/common_paths.h b/src/common/src/common_paths.h index b38ae6903..fae810bf0 100644 --- a/src/common/src/common_paths.h +++ b/src/common/src/common_paths.h @@ -12,7 +12,9 @@ #define DIR_SEP "/" #define DIR_SEP_CHR '/' -#define MAX_PATH 255 +#ifndef MAX_PATH +#define MAX_PATH 260 +#endif // The user data dir #define ROOT_DIR "." @@ -60,6 +62,7 @@ #define DUMP_AUDIO_DIR "audio" #define LOGS_DIR "logs" #define SHADERS_DIR "shaders" +#define SYSCONF_DIR "sysconf" // Filenames // Files in the directory returned by GetUserPath(D_CONFIG_IDX) @@ -68,6 +71,9 @@ #define LOGGER_CONFIG "logger.ini" // Files in the directory returned by GetUserPath(D_LOGS_IDX) -#define MAIN_LOG "akiru.log" +#define MAIN_LOG "emu.log" + +// Files in the directory returned by GetUserPath(D_SYSCONF_IDX) +#define SYSCONF "SYSCONF" #endif // _COMMON_PATHS_H_ diff --git a/src/common/src/file_util.cpp b/src/common/src/file_util.cpp index f86414bf3..6a7f92754 100644 --- a/src/common/src/file_util.cpp +++ b/src/common/src/file_util.cpp @@ -657,129 +657,117 @@ std::string GetSysDirectory() // Returns a string with a Dolphin data dir or file in the user's home // directory. To be used in "multi-user" mode (that is, installed). -//const std::string& GetUserPath(const unsigned int DirIDX, const std::string &newPath) -//{ -// static std::string paths[NUM_PATH_INDICES]; -// -// // Set up all paths and files on the first run -// if (paths[D_USER_IDX].empty()) -// { -//#ifdef _WIN32 -// paths[D_USER_IDX] = GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP; -//#else -// if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) -// paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP; -// else -// paths[D_USER_IDX] = std::string(getenv("HOME") ? -// getenv("HOME") : getenv("PWD") ? -// getenv("PWD") : "") + DIR_SEP DOLPHIN_DATA_DIR DIR_SEP; -//#endif -// -// paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; -// paths[D_GAMECONFIG_IDX] = paths[D_USER_IDX] + GAMECONFIG_DIR DIR_SEP; -// paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP; -// paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; -// paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; -// paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; -// paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; -// paths[D_SCREENSHOTS_IDX] = paths[D_USER_IDX] + SCREENSHOTS_DIR DIR_SEP; -// paths[D_DUMP_IDX] = paths[D_USER_IDX] + DUMP_DIR DIR_SEP; -// paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; -// paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; -// paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; -// paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP; -// paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; -// paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; -// paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; -// } -// -// if (!newPath.empty()) -// { -// if (!File::IsDirectory(newPath)) -// { -// WARN_LOG(COMMON, "Invalid path specified %s", newPath.c_str()); -// return paths[DirIDX]; -// } -// else -// { -// paths[DirIDX] = newPath; -// } -// -// switch (DirIDX) -// { -// case D_WIIROOT_IDX: -// paths[D_WIIUSER_IDX] = paths[D_WIIROOT_IDX] + DIR_SEP; -// paths[D_WIISYSCONF_IDX] = paths[D_WIIUSER_IDX] + WII_SYSCONF_DIR + DIR_SEP; -// paths[F_WIISYSCONF_IDX] = paths[D_WIISYSCONF_IDX] + WII_SYSCONF; -// break; -// -// case D_USER_IDX: -// paths[D_GCUSER_IDX] = paths[D_USER_IDX] + GC_USER_DIR DIR_SEP; -// paths[D_WIIROOT_IDX] = paths[D_USER_IDX] + WII_USER_DIR; -// paths[D_WIIUSER_IDX] = paths[D_WIIROOT_IDX] + DIR_SEP; -// paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; -// paths[D_GAMECONFIG_IDX] = paths[D_USER_IDX] + GAMECONFIG_DIR DIR_SEP; -// paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP; -// paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; -// paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; -// paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; -// paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; -// paths[D_SCREENSHOTS_IDX] = paths[D_USER_IDX] + SCREENSHOTS_DIR DIR_SEP; -// paths[D_OPENCL_IDX] = paths[D_USER_IDX] + OPENCL_DIR DIR_SEP; -// paths[D_HIRESTEXTURES_IDX] = paths[D_USER_IDX] + HIRES_TEXTURES_DIR DIR_SEP; -// paths[D_DUMP_IDX] = paths[D_USER_IDX] + DUMP_DIR DIR_SEP; -// paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; -// paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; -// paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; -// paths[D_DUMPDSP_IDX] = paths[D_DUMP_IDX] + DUMP_DSP_DIR DIR_SEP; -// paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP; -// paths[D_MAILLOGS_IDX] = paths[D_LOGS_IDX] + MAIL_LOGS_DIR DIR_SEP; -// paths[D_WIISYSCONF_IDX] = paths[D_WIIUSER_IDX] + WII_SYSCONF_DIR DIR_SEP; -// paths[D_THEMES_IDX] = paths[D_USER_IDX] + THEMES_DIR DIR_SEP; -// paths[F_DOLPHINCONFIG_IDX] = paths[D_CONFIG_IDX] + DOLPHIN_CONFIG; -// paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; -// paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; -// paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; -// paths[F_WIISYSCONF_IDX] = paths[D_WIISYSCONF_IDX] + WII_SYSCONF; -// paths[F_RAMDUMP_IDX] = paths[D_DUMP_IDX] + RAM_DUMP; -// paths[F_ARAMDUMP_IDX] = paths[D_DUMP_IDX] + ARAM_DUMP; -// paths[F_FAKEVMEMDUMP_IDX] = paths[D_DUMP_IDX] + FAKEVMEM_DUMP; -// paths[F_GCSRAM_IDX] = paths[D_GCUSER_IDX] + GC_SRAM; -// break; -// -// case D_CONFIG_IDX: -// paths[F_DOLPHINCONFIG_IDX] = paths[D_CONFIG_IDX] + DOLPHIN_CONFIG; -// paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; -// paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; -// break; -// -// case D_DUMP_IDX: -// paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; -// paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; -// paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; -// break; -// -// case D_LOGS_IDX: -// paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; -// } -// } -// -// return paths[DirIDX]; -//} - -std::string GetThemeDir(const std::string& theme_name) +const std::string& GetUserPath(const unsigned int DirIDX, const std::string &newPath) { - std::string dir = File::GetUserPath(D_THEMES_IDX) + theme_name + "/"; + static std::string paths[NUM_PATH_INDICES]; -#if !defined(_WIN32) - // If theme does not exist in user's dir load from shared directory - if (!File::Exists(dir)) - dir = SHARED_USER_DIR THEMES_DIR "/" + theme_name + "/"; + // Set up all paths and files on the first run + if (paths[D_USER_IDX].empty()) + { +#ifdef _WIN32 + paths[D_USER_IDX] = GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP; +#else + if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) + paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP; + else + paths[D_USER_IDX] = std::string(getenv("HOME") ? + getenv("HOME") : getenv("PWD") ? + getenv("PWD") : "") + DIR_SEP DOLPHIN_DATA_DIR DIR_SEP; #endif + + paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; + paths[D_GAMECONFIG_IDX] = paths[D_USER_IDX] + GAMECONFIG_DIR DIR_SEP; + paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP; + paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; + paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; + paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; + paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; + paths[D_SCREENSHOTS_IDX] = paths[D_USER_IDX] + SCREENSHOTS_DIR DIR_SEP; + paths[D_DUMP_IDX] = paths[D_USER_IDX] + DUMP_DIR DIR_SEP; + paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; + paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; + paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; + paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP; + paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; + paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; + paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; + } + + if (!newPath.empty()) + { + if (!File::IsDirectory(newPath)) + { + WARN_LOG(COMMON, "Invalid path specified %s", newPath.c_str()); + return paths[DirIDX]; + } + else + { + paths[DirIDX] = newPath; + } + + switch (DirIDX) + { + case D_ROOT_IDX: + paths[D_USER_IDX] = paths[D_ROOT_IDX] + DIR_SEP; + paths[D_SYSCONF_IDX] = paths[D_USER_IDX] + SYSCONF_DIR + DIR_SEP; + paths[F_SYSCONF_IDX] = paths[D_SYSCONF_IDX] + SYSCONF; + break; + + case D_USER_IDX: + paths[D_USER_IDX] = paths[D_ROOT_IDX] + DIR_SEP; + paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; + paths[D_GAMECONFIG_IDX] = paths[D_USER_IDX] + GAMECONFIG_DIR DIR_SEP; + paths[D_MAPS_IDX] = paths[D_USER_IDX] + MAPS_DIR DIR_SEP; + paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; + paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; + paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; + paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; + paths[D_SCREENSHOTS_IDX] = paths[D_USER_IDX] + SCREENSHOTS_DIR DIR_SEP; + paths[D_DUMP_IDX] = paths[D_USER_IDX] + DUMP_DIR DIR_SEP; + paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; + paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; + paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; + paths[D_LOGS_IDX] = paths[D_USER_IDX] + LOGS_DIR DIR_SEP; + paths[D_SYSCONF_IDX] = paths[D_USER_IDX] + SYSCONF_DIR DIR_SEP; + paths[F_EMUCONFIG_IDX] = paths[D_CONFIG_IDX] + EMU_CONFIG; + paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; + paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; + paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; + break; + + case D_CONFIG_IDX: + paths[F_EMUCONFIG_IDX] = paths[D_CONFIG_IDX] + EMU_CONFIG; + paths[F_DEBUGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + DEBUGGER_CONFIG; + paths[F_LOGGERCONFIG_IDX] = paths[D_CONFIG_IDX] + LOGGER_CONFIG; + break; + + case D_DUMP_IDX: + paths[D_DUMPFRAMES_IDX] = paths[D_DUMP_IDX] + DUMP_FRAMES_DIR DIR_SEP; + paths[D_DUMPAUDIO_IDX] = paths[D_DUMP_IDX] + DUMP_AUDIO_DIR DIR_SEP; + paths[D_DUMPTEXTURES_IDX] = paths[D_DUMP_IDX] + DUMP_TEXTURES_DIR DIR_SEP; + break; + + case D_LOGS_IDX: + paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; + } + } - return dir; + return paths[DirIDX]; } +//std::string GetThemeDir(const std::string& theme_name) +//{ +// std::string dir = File::GetUserPath(D_THEMES_IDX) + theme_name + "/"; +// +//#if !defined(_WIN32) +// // If theme does not exist in user's dir load from shared directory +// if (!File::Exists(dir)) +// dir = SHARED_USER_DIR THEMES_DIR "/" + theme_name + "/"; +//#endif +// +// return dir; +//} + bool WriteStringToFile(bool text_file, const std::string &str, const char *filename) { return File::IOFile(filename, text_file ? "w" : "wb").WriteBytes(str.data(), str.size()); diff --git a/src/common/src/file_util.h b/src/common/src/file_util.h index a6bd085ab..f4ef949d8 100644 --- a/src/common/src/file_util.h +++ b/src/common/src/file_util.h @@ -18,9 +18,7 @@ // User directory indices for GetUserPath enum { D_USER_IDX, - D_GCUSER_IDX, - D_WIIROOT_IDX, - D_WIIUSER_IDX, + D_ROOT_IDX, D_CONFIG_IDX, D_GAMECONFIG_IDX, D_MAPS_IDX, @@ -29,7 +27,6 @@ enum { D_SHADERS_IDX, D_STATESAVES_IDX, D_SCREENSHOTS_IDX, - D_OPENCL_IDX, D_HIRESTEXTURES_IDX, D_DUMP_IDX, D_DUMPFRAMES_IDX, @@ -37,19 +34,14 @@ enum { D_DUMPTEXTURES_IDX, D_DUMPDSP_IDX, D_LOGS_IDX, - D_MAILLOGS_IDX, - D_WIISYSCONF_IDX, - D_WIIWC24_IDX, - D_THEMES_IDX, - F_DOLPHINCONFIG_IDX, + D_SYSCONF_IDX, + F_EMUCONFIG_IDX, F_DEBUGGERCONFIG_IDX, F_LOGGERCONFIG_IDX, F_MAINLOG_IDX, - F_WIISYSCONF_IDX, F_RAMDUMP_IDX, F_ARAMDUMP_IDX, - F_FAKEVMEMDUMP_IDX, - F_GCSRAM_IDX, + F_SYSCONF_IDX, NUM_PATH_INDICES }; @@ -124,7 +116,7 @@ bool SetCurrentDir(const std::string &directory); const std::string& GetUserPath(const unsigned int DirIDX, const std::string &newPath=""); // probably doesn't belong here -std::string GetThemeDir(const std::string& theme_name); +//std::string GetThemeDir(const std::string& theme_name); // Returns the path to where the sys file are std::string GetSysDirectory(); |