diff options
| author | Glenn Rice <glennricster@gmail.com> | 2010-02-02 21:56:29 +0000 |
|---|---|---|
| committer | Glenn Rice <glennricster@gmail.com> | 2010-02-02 21:56:29 +0000 |
| commit | feba09f7a3e8d8e9b1ea2fe0d666c5be82941096 (patch) | |
| tree | e695da77bfbd419355df9d29c799f6722d64ccef /Source/Core/Common | |
| parent | a090876bbd89ac656db2c1a5b81b778311b1c804 (diff) | |
Linux global build. At least the basic footwork is done here.
Basic usage: "sudo scons install=global install"
Hopefully this doesn't break builds on Macs. I have tested this on linux and windows.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4994 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/Src/CommonPaths.h | 186 | ||||
| -rw-r--r-- | Source/Core/Common/Src/FileUtil.cpp | 214 | ||||
| -rw-r--r-- | Source/Core/Common/Src/FileUtil.h | 42 | ||||
| -rw-r--r-- | Source/Core/Common/Src/LogManager.cpp | 7 | ||||
| -rw-r--r-- | Source/Core/Common/Src/LogManager.h | 2 | ||||
| -rw-r--r-- | Source/Core/Common/Src/SysConf.cpp | 14 | ||||
| -rw-r--r-- | Source/Core/Common/Src/SysConf.h | 2 |
7 files changed, 317 insertions, 150 deletions
diff --git a/Source/Core/Common/Src/CommonPaths.h b/Source/Core/Common/Src/CommonPaths.h index 3d26c0b4c9..36ad84fad2 100644 --- a/Source/Core/Common/Src/CommonPaths.h +++ b/Source/Core/Common/Src/CommonPaths.h @@ -18,6 +18,10 @@ #ifndef _COMMON_PATHS_H_ #define _COMMON_PATHS_H_ +#ifdef __linux__ +#include "Config.h" +#endif + // Library suffix/prefix #ifdef _WIN32 #define PLUGIN_PREFIX "" @@ -34,18 +38,25 @@ #define DIR_SEP "/" #define DIR_SEP_CHR '/' -#if defined __APPLE__ +// Location of the plugins +#ifdef LIBS_DIR +#define PLUGINS_DIR LIBS_DIR "dolphin-emu" +#elif defined __APPLE__ #define PLUGINS_DIR "Contents/PlugIns" -#define SYSDATA_DIR "Contents/Sys" #else #define PLUGINS_DIR "Plugins" -#define SYSDATA_DIR "Sys" #endif + +// The user data dir #define ROOT_DIR "." +#ifdef __linux__ +#define USERDATA_DIR "user" +#else #define USERDATA_DIR "User" - -// Where data directory is -#ifdef _WIN32 +#endif +#ifdef USER_DIR +#define DOLPHIN_DATA_DIR USER_DIR +#elif defined _WIN32 #define DOLPHIN_DATA_DIR "Dolphin" #elif defined __APPLE__ #define DOLPHIN_DATA_DIR "Library/Application Support/Dolphin" @@ -53,119 +64,101 @@ #define DOLPHIN_DATA_DIR ".dolphin" #endif +// Shared data dirs (Sys and shared User for linux) +#ifdef DATA_DIR +#define SYSDATA_DIR DATA_DIR "Sys" +#define SHARED_USER_DIR DATA_DIR USERDATA_DIR DIR_SEP +#elif defined __APPLE__ +#define SYSDATA_DIR "Contents/Sys" +#elif defined __linux__ +#define SYSDATA_DIR "sys" +#define SHARED_USER_DIR ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP +#else +#define SYSDATA_DIR "Sys" +#endif + // Dirs in both User and Sys #define EUR_DIR "EUR" #define USA_DIR "USA" #define JAP_DIR "JAP" -// Dirs in User -#define GC_USER_DIR "GC" -#define WII_USER_DIR "Wii" -#define WII_SYSCONF_DIR "shared2/sys" -#define CONFIG_DIR "Config" -#define GAMECONFIG_DIR "GameConfig" -#define MAPS_DIR "Maps" -#define CACHE_DIR "Cache" -#define SHADERCACHE_DIR "ShaderCache" -#define STATESAVES_DIR "StateSaves" -#define SCREENSHOTS_DIR "ScreenShots" -#define DUMP_DIR "Dump" -#define DUMP_TEXTURES_DIR "Textures" -#define LOAD_DIR "Load" -#define HIRES_TEXTURES_DIR "Textures" -#define DUMP_FRAMES_DIR "Frames" -#define DUMP_DSP_DIR "DSP" -#define LOGS_DIR "Logs" -#define MAIL_LOGS_DIR "Mail" - -// Dirs in Sys -#define GC_SYS_DIR "GC" -#define WII_SYS_DIR "Wii" +// Subdirs in the User dir returned by GetUserPath(D_USER_IDX) +#define GC_USER_DIR "GC" +#define WII_USER_DIR "Wii" +#define CONFIG_DIR "Config" +#define GAMECONFIG_DIR "GameConfig" +#define MAPS_DIR "Maps" +#define CACHE_DIR "Cache" +#define SHADERCACHE_DIR "ShaderCache" +#define STATESAVES_DIR "StateSaves" +#define SCREENSHOTS_DIR "ScreenShots" +#define LOAD_DIR "Load" +#define HIRES_TEXTURES_DIR LOAD_DIR DIR_SEP "Textures" +#define DUMP_DIR "Dump" +#define DUMP_TEXTURES_DIR DUMP_DIR DIR_SEP "Textures" +#define DUMP_FRAMES_DIR DUMP_DIR DIR_SEP "Frames" +#define DUMP_DSP_DIR DUMP_DIR DIR_SEP "DSP" +#define LOGS_DIR "Logs" +#define MAIL_LOGS_DIR LOGS_DIR DIR_SEP "Mail" +#define SHADERS_DIR "Shaders" +#define WII_SYSCONF_DIR WII_USER_DIR DIR_SEP "shared2" DIR_SEP "sys" +#define WII_MENU_DIR WII_USER_DIR DIR_SEP "title" DIR_SEP "00000001" DIR_SEP "00000002" DIR_SEP "content" // Filenames -#define DOLPHIN_CONFIG "Dolphin.ini" -#define DEBUGGER_CONFIG "Debugger.ini" -#define LOGGER_CONFIG "Logger.ini" -#define TOTALDB "totaldb.dsy" -#define MAIN_LOG "dolphin.log" +// Files in the directory returned by GetUserPath(D_CONFIG_IDX) +#define DOLPHIN_CONFIG "Dolphin.ini" +#define DEBUGGER_CONFIG "Debugger.ini" +#define LOGGER_CONFIG "Logger.ini" + +// Files in the directory returned by GetUserPath(D_LOGS_IDX) +#define MAIN_LOG "dolphin.log" + +// Files in the directory returned by GetUserPath(D_WIISYSCONF_IDX) +#define WII_SYSCONF "SYSCONF" +// Files in the directory returned by GetUserPath(D_DUMP_IDX) +#define RAM_DUMP "ram.raw" +#define ARAM_DUMP "aram.raw" + +// Plugin files #define DEFAULT_GFX_PLUGIN PLUGIN_PREFIX "Plugin_VideoOGL" PLUGIN_SUFFIX #define DEFAULT_DSP_PLUGIN PLUGIN_PREFIX "Plugin_DSP_HLE" PLUGIN_SUFFIX #define DEFAULT_PAD_PLUGIN PLUGIN_PREFIX "Plugin_GCPad" PLUGIN_SUFFIX #define DEFAULT_WIIMOTE_PLUGIN PLUGIN_PREFIX "Plugin_Wiimote" PLUGIN_SUFFIX -#define FONT_ANSI "font_ansi.bin" -#define FONT_SJIS "font_sjis.bin" +// Sys files +#define TOTALDB "totaldb.dsy" + +#define FONT_ANSI "font_ansi.bin" +#define FONT_SJIS "font_sjis.bin" -#define DSP_IROM "dsp_rom.bin" -#define DSP_COEF "dsp_coef.bin" +#define DSP_IROM "dsp_rom.bin" +#define DSP_COEF "dsp_coef.bin" -#define GC_IPL "IPL.bin" -#define GC_SRAM "SRAM.raw" -#define GC_MEMCARDA "MemoryCardA" -#define GC_MEMCARDB "MemoryCardB" +#define GC_IPL "IPL.bin" +#define GC_SRAM "SRAM.raw" +#define GC_MEMCARDA "MemoryCardA" +#define GC_MEMCARDB "MemoryCardB" #define WII_EUR_SETTING "setting-eur.txt" #define WII_USA_SETTING "setting-usa.txt" #define WII_JAP_SETTING "setting-jpn.txt" -#define WII_SYSCONF "SYSCONF" - -#define RAM_DUMP "ram.raw" -#define ARAM_DUMP "aram.raw" - -// Shorts - dirs -// User dirs -#define FULL_USERDATA_DIR ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP -#define T_FULLUSERDATA_DIR _T(ROOT_DIR) _T(DIR_SEP) _T(USERDATA_DIR) _T(DIR_SEP) - -#define FULL_GC_USER_DIR FULL_USERDATA_DIR GC_USER_DIR DIR_SEP -#define T_FULL_GC_USER_DIR T_FULLUSERDATA_DIR _T(GC_USER_DIR) _T(DIR_SEP) - -#define FULL_WII_USER_DIR FULL_USERDATA_DIR WII_USER_DIR DIR_SEP -#define FULL_WII_ROOT_DIR FULL_USERDATA_DIR WII_USER_DIR // This is the "root" for Wii fs, so that it may be used with created devices - -#define FULL_GAMECONFIG_DIR FULL_USERDATA_DIR GAMECONFIG_DIR DIR_SEP -#define T_FULL_GAMECONFIG_DIR T_FULLUSERDATA_DIR _T(GAMECONFIG_DIR) _T(DIR_SEP) - -#define FULL_CONFIG_DIR FULL_USERDATA_DIR CONFIG_DIR DIR_SEP -#define FULL_CACHE_DIR FULL_USERDATA_DIR CACHE_DIR DIR_SEP -#define FULL_SHADERCACHE_DIR FULL_USERDATA_DIR SHADERCACHE_DIR DIR_SEP -#define FULL_STATESAVES_DIR FULL_USERDATA_DIR STATESAVES_DIR DIR_SEP -#define FULL_SCREENSHOTS_DIR FULL_USERDATA_DIR SCREENSHOTS_DIR DIR_SEP -#define FULL_FRAMES_DIR FULL_USERDATA_DIR DUMP_DIR DIR_SEP DUMP_FRAMES_DIR -#define FULL_DUMP_DIR FULL_USERDATA_DIR DUMP_DIR DIR_SEP -#define FULL_DUMP_TEXTURES_DIR FULL_USERDATA_DIR DUMP_DIR DIR_SEP DUMP_TEXTURES_DIR DIR_SEP -#define FULL_HIRES_TEXTURES_DIR FULL_USERDATA_DIR LOAD_DIR DIR_SEP HIRES_TEXTURES_DIR DIR_SEP -#define FULL_DSP_DUMP_DIR FULL_USERDATA_DIR DUMP_DIR DIR_SEP DUMP_DSP_DIR DIR_SEP -#define FULL_LOGS_DIR FULL_USERDATA_DIR LOGS_DIR DIR_SEP -#define FULL_MAIL_LOGS_DIR FULL_LOGS_DIR MAIL_LOGS_DIR DIR_SEP -#define FULL_MAPS_DIR FULL_USERDATA_DIR MAPS_DIR DIR_SEP -#define FULL_WII_SYSCONF_DIR FULL_WII_USER_DIR WII_SYSCONF_DIR DIR_SEP - -// Sys dirs -#define FULL_SYSDATA_DIR ROOT_DIR DIR_SEP SYSDATA_DIR DIR_SEP -#define FULL_GC_SYS_DIR FULL_SYSDATA_DIR GC_SYS_DIR DIR_SEP -//#define GC_SYS_EUR_DIR FULL_GC_SYS_DIR EUR_DIR -//#define GC_SYS_USA_DIR FULL_GC_SYS_DIR USA_DIR -//#define GC_SYS_JAP_DIR FULL_GC_SYS_DIR JAP_DIR +// Subdirs in Sys +#define GC_SYS_DIR "GC" +#define WII_SYS_DIR "Wii" +// Full Sys dirs +#define FULL_SYSDATA_DIR ROOT_DIR DIR_SEP SYSDATA_DIR DIR_SEP +#define FULL_GC_SYS_DIR FULL_SYSDATA_DIR GC_SYS_DIR DIR_SEP +//#define GC_SYS_EUR_DIR FULL_GC_SYS_DIR EUR_DIR +//#define GC_SYS_USA_DIR FULL_GC_SYS_DIR USA_DIR +//#define GC_SYS_JAP_DIR FULL_GC_SYS_DIR JAP_DIR #define FULL_WII_SYS_DIR FULL_SYSDATA_DIR WII_SYS_DIR DIR_SEP -// Shorts - files -// User files -#define CONFIG_FILE FULL_CONFIG_DIR DOLPHIN_CONFIG -#define DEBUGGER_CONFIG_FILE FULL_CONFIG_DIR DEBUGGER_CONFIG -#define LOGGER_CONFIG_FILE FULL_CONFIG_DIR LOGGER_CONFIG - -#define TOTALDB_FILE FULL_SYSDATA_DIR TOTALDB -#define MAINRAM_DUMP_FILE FULL_DUMP_DIR RAM_DUMP -#define ARAM_DUMP_FILE FULL_DUMP_DIR ARAM_DUMP -#define GC_SRAM_FILE FULL_USERDATA_DIR GC_USER_DIR DIR_SEP GC_SRAM +// Sys files with full path +#define TOTALDB_FILE FULL_SYSDATA_DIR TOTALDB -#define MAIN_LOG_FILE FULL_LOGS_DIR MAIN_LOG - -// Sys files #define FONT_ANSI_FILE FULL_GC_SYS_DIR FONT_ANSI #define FONT_SJIS_FILE FULL_GC_SYS_DIR FONT_SJIS @@ -175,8 +168,5 @@ #define WII_EUR_SETTING_FILE FULL_WII_SYS_DIR WII_EUR_SETTING #define WII_USA_SETTING_FILE FULL_WII_SYS_DIR WII_USA_SETTING #define WII_JAP_SETTING_FILE FULL_WII_SYS_DIR WII_JAP_SETTING -#define WII_SYSCONF_FILE FULL_WII_SYSCONF_DIR WII_SYSCONF - -#define FULL_WII_MENU_DIR FULL_WII_USER_DIR "title" DIR_SEP "00000001" DIR_SEP "00000002" DIR_SEP "content" #endif // _COMMON_PATHS_H_ diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 7a8410fd0c..9688e41fdc 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -487,6 +487,41 @@ bool DeleteDirRecursively(const char *directory) return true; } +#ifdef __linux__ +//Create directory and copy contents (does not overwrite existing files) +void CopyDir(const char *source_path, const char *dest_path) +{ + if (!File::Exists(source_path)) + return; + + if (!File::Exists(dest_path)) File::CreateFullPath(dest_path); + char *virtualName; + struct dirent dirent, *result = NULL; + DIR *dirp = opendir(source_path); + if (!dirp) + return; + while (!readdir_r(dirp, &dirent, &result) && result) { + virtualName = result->d_name; + // check for "." and ".." + if (((virtualName[0] == '.') && (virtualName[1] == '\0')) || + ((virtualName[0] == '.') && (virtualName[1] == '.') && + (virtualName[2] == '\0'))) + continue; + char source[300], dest[300]; + sprintf(source, "%s%s", source_path, virtualName); + sprintf(dest, "%s%s", dest_path, virtualName); + if (IsDirectory(source)) { + sprintf(source, "%s/", source); + sprintf(dest, "%s/", dest); + if (!File::Exists(dest)) File::CreateFullPath(dest); + CopyDir(source, dest); + } else + if (!File::Exists(dest)) File::Copy(source, dest); + } + closedir(dirp); +} +#endif + // Returns the current directory std::string GetCurrentDir() { @@ -510,28 +545,6 @@ bool SetCurrentDir(const char *_rDirectory) } #if defined(__APPLE__) - -//get the full config dir -const char *GetConfigDirectory() -{ - static char path[MAX_PATH] = {0}; - if (strlen(path) > 0) - return path; - snprintf(path, sizeof(path), "%s" DIR_SEP CONFIG_FILE, GetUserDirectory()); - return path; -} - -//get the full SYSCONF dir -const char *GetSysConfDirectory() -{ - static char path[MAX_PATH] = {0}; - if (strlen(path) > 0) - return path; - snprintf(path, sizeof(path), "%s" DIR_SEP WII_SYSCONF_FILE, GetUserDirectory()); - return path; - -} - std::string GetBundleDirectory() { // Plugin path will be Dolphin.app/Contents/PlugIns @@ -599,28 +612,149 @@ std::string GetSysDirectory() return sysDir; } -// Returns a pointer to a string with a Dolphin data dir in the user's home +// Returns a pointer to 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 char *GetUserDirectory() +const char *GetUserPath(int DirIDX) { - // Make sure we only need to do it once - static char path[MAX_PATH] = {0}; - if (strlen(path) > 0) - return path; - -#ifdef WIN32 - char homedir[MAX_PATH]; - if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path))) - return NULL; + static char UserDir[MAX_PATH] = {0}; + static char GCUserDir[MAX_PATH] = {0}; + static char WiiUserDir[MAX_PATH] = {0}; + static char ConfigDir[MAX_PATH] = {0}; + static char GameConfigDir[MAX_PATH] = {0}; + static char MapsDir[MAX_PATH] = {0}; + static char CacheDir[MAX_PATH] = {0}; + static char ShaderCacheDir[MAX_PATH] = {0}; + static char ShadersDir[MAX_PATH] = {0}; + static char StateSavesDir[MAX_PATH] = {0}; + static char ScreenShotsDir[MAX_PATH] = {0}; + static char HiresTexturesDir[MAX_PATH] = {0}; + static char DumpDir[MAX_PATH] = {0}; + static char DumpFramesDir[MAX_PATH] = {0}; + static char DumpTexturesDir[MAX_PATH] = {0}; + static char DumpDSPDir[MAX_PATH] = {0}; + static char LogsDir[MAX_PATH] = {0}; + static char MailLogsDir[MAX_PATH] = {0}; + static char WiiSYSCONFDir[MAX_PATH] = {0}; + static char WiiMenuDir[MAX_PATH] = {0}; + static char DolphinConfig[MAX_PATH] = {0}; + static char DebuggerConfig[MAX_PATH] = {0}; + static char LoggerConfig[MAX_PATH] = {0}; + static char MainLog[MAX_PATH] = {0}; + static char WiiSYSCONF[MAX_PATH] = {0}; + static char RamDump[MAX_PATH] = {0}; + static char ARamDump[MAX_PATH] = {0}; + static char GCSRam[MAX_PATH] = {0}; + + // Set up all paths and files on the first run + if (strlen(UserDir) == 0) + { +#ifdef _WIN32 + // Keep the directory setup the way it was on windows + snprintf(UserDir, sizeof(UserDir), ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP); + //char homedir[MAX_PATH]; + //if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path))) + // return NULL; #else - char *homedir = getenv("HOME"); - if (!homedir) - return NULL; + if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) + snprintf(UserDir, sizeof(UserDir), ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP); + else + { + char *homedir = getenv("HOME"); + if (homedir) + snprintf(UserDir, sizeof(UserDir), "%s" DIR_SEP DOLPHIN_DATA_DIR DIR_SEP, homedir); + } #endif - - snprintf(path, sizeof(path), "%s" DIR_SEP DOLPHIN_DATA_DIR, homedir); - INFO_LOG(COMMON, "GetUserDirectory: Setting to %s:", path); - return path; + INFO_LOG(COMMON, "GetUserPath: Setting user directory to %s:", UserDir); + + snprintf(GCUserDir, sizeof(GCUserDir), "%s" GC_USER_DIR DIR_SEP, UserDir); + snprintf(WiiUserDir, sizeof(WiiUserDir), "%s" WII_USER_DIR DIR_SEP, UserDir); + snprintf(ConfigDir, sizeof(ConfigDir), "%s" CONFIG_DIR DIR_SEP, UserDir); + snprintf(GameConfigDir, sizeof(GameConfigDir), "%s" GAMECONFIG_DIR DIR_SEP, UserDir); + snprintf(MapsDir, sizeof(MapsDir), "%s" MAPS_DIR DIR_SEP, UserDir); + snprintf(CacheDir, sizeof(CacheDir), "%s" CACHE_DIR DIR_SEP, UserDir); + snprintf(ShaderCacheDir, sizeof(ShaderCacheDir), "%s" SHADERCACHE_DIR DIR_SEP, UserDir); + snprintf(ShadersDir, sizeof(ShadersDir), "%s" SHADERS_DIR DIR_SEP, UserDir); + snprintf(StateSavesDir, sizeof(StateSavesDir), "%s" STATESAVES_DIR DIR_SEP, UserDir); + snprintf(ScreenShotsDir, sizeof(ScreenShotsDir), "%s" SCREENSHOTS_DIR DIR_SEP, UserDir); + snprintf(HiresTexturesDir, sizeof(HiresTexturesDir), "%s" HIRES_TEXTURES_DIR DIR_SEP, UserDir); + snprintf(DumpDir, sizeof(DumpDir), "%s" DUMP_DIR DIR_SEP, UserDir); + snprintf(DumpFramesDir, sizeof(DumpFramesDir), "%s" DUMP_FRAMES_DIR DIR_SEP, UserDir); + snprintf(DumpTexturesDir, sizeof(DumpTexturesDir), "%s" DUMP_TEXTURES_DIR DIR_SEP, UserDir); + snprintf(DumpDSPDir, sizeof(DumpDSPDir), "%s" DUMP_DSP_DIR DIR_SEP, UserDir); + snprintf(LogsDir, sizeof(LogsDir), "%s" LOGS_DIR DIR_SEP, UserDir); + snprintf(MailLogsDir, sizeof(MailLogsDir), "%s" MAIL_LOGS_DIR DIR_SEP, UserDir); + snprintf(WiiSYSCONFDir, sizeof(WiiSYSCONFDir), "%s" WII_SYSCONF_DIR DIR_SEP, UserDir); + snprintf(WiiMenuDir, sizeof(WiiMenuDir), "%s" WII_MENU_DIR DIR_SEP, UserDir); + snprintf(DolphinConfig, sizeof(DolphinConfig), "%s" DOLPHIN_CONFIG, ConfigDir); + snprintf(DebuggerConfig, sizeof(DebuggerConfig), "%s" DEBUGGER_CONFIG, ConfigDir); + snprintf(LoggerConfig, sizeof(LoggerConfig), "%s" LOGGER_CONFIG, ConfigDir); + snprintf(MainLog, sizeof(MainLog), "%s" MAIN_LOG, LogsDir); + snprintf(WiiSYSCONF, sizeof(WiiSYSCONF), "%s" WII_SYSCONF, WiiSYSCONFDir); + snprintf(RamDump, sizeof(RamDump), "%s" RAM_DUMP, DumpDir); + snprintf(ARamDump, sizeof(ARamDump), "%s" ARAM_DUMP, DumpDir); + snprintf(GCSRam, sizeof(GCSRam), "%s" GC_SRAM, GCUserDir); + } + switch (DirIDX) + { + case D_USER_IDX: + return UserDir; + case D_GCUSER_IDX: + return GCUserDir; + case D_WIIUSER_IDX: + return WiiUserDir; + case D_CONFIG_IDX: + return ConfigDir; + case D_GAMECONFIG_IDX: + return GameConfigDir; + case D_MAPS_IDX: + return MapsDir; + case D_CACHE_IDX: + return CacheDir; + case D_SHADERCACHE_IDX: + return ShaderCacheDir; + case D_SHADERS_IDX: + return ShadersDir; + case D_STATESAVES_IDX: + return StateSavesDir; + case D_SCREENSHOTS_IDX: + return ScreenShotsDir; + case D_HIRESTEXTURES_IDX: + return HiresTexturesDir; + case D_DUMP_IDX: + return DumpDir; + case D_DUMPFRAMES_IDX: + return DumpFramesDir; + case D_DUMPTEXTURES_IDX: + return DumpTexturesDir; + case D_DUMPDSP_IDX: + return DumpDSPDir; + case D_LOGS_IDX: + return LogsDir; + case D_MAILLOGS_IDX: + return MailLogsDir; + case D_WIISYSCONF_IDX: + return WiiSYSCONFDir; + case D_WIIMENU_IDX: + return WiiMenuDir; + case F_DOLPHINCONFIG_IDX: + return DolphinConfig; + case F_DEBUGGERCONFIG_IDX: + return DebuggerConfig; + case F_LOGGERCONFIG_IDX: + return LoggerConfig; + case F_MAINLOG_IDX: + return MainLog; + case F_WIISYSCONF_IDX: + return WiiSYSCONF; + case F_RAMDUMP_IDX: + return RamDump; + case F_ARAMDUMP_IDX: + return ARamDump; + case F_GCSRAM_IDX: + return GCSRam; + default: + return NULL; + } } bool WriteStringToFile(bool text_file, const std::string &str, const char *filename) diff --git a/Source/Core/Common/Src/FileUtil.h b/Source/Core/Common/Src/FileUtil.h index 728ad46f8a..f180b8faf0 100644 --- a/Source/Core/Common/Src/FileUtil.h +++ b/Source/Core/Common/Src/FileUtil.h @@ -24,6 +24,38 @@ #include "Common.h" +// User directory indices for GetUserPath +enum { + D_USER_IDX, + D_GCUSER_IDX, + D_WIIUSER_IDX, + D_CONFIG_IDX, + D_GAMECONFIG_IDX, + D_MAPS_IDX, + D_CACHE_IDX, + D_SHADERCACHE_IDX, + D_SHADERS_IDX, + D_STATESAVES_IDX, + D_SCREENSHOTS_IDX, + D_HIRESTEXTURES_IDX, + D_DUMP_IDX, + D_DUMPFRAMES_IDX, + D_DUMPTEXTURES_IDX, + D_DUMPDSP_IDX, + D_LOGS_IDX, + D_MAILLOGS_IDX, + D_WIISYSCONF_IDX, + D_WIIMENU_IDX, + F_DOLPHINCONFIG_IDX, + F_DEBUGGERCONFIG_IDX, + F_LOGGERCONFIG_IDX, + F_MAINLOG_IDX, + F_WIISYSCONF_IDX, + F_RAMDUMP_IDX, + F_ARAMDUMP_IDX, + F_GCSRAM_IDX, +}; + namespace File { @@ -78,13 +110,15 @@ bool DeleteDirRecursively(const char *directory); // Returns the current directory std::string GetCurrentDir(); +//Create directory and copy contents (does not overwrite existing files) +void CopyDir(const char *source_path, const char *dest_path); + // Set the current directory to given directory bool SetCurrentDir(const char *directory); - // Returns a pointer to a string with a Dolphin data dir in the user's home // directory. To be used in "multi-user" mode (that is, installed). -const char *GetUserDirectory(); +const char *GetUserPath(int DirIDX); // Returns the path to where the plugins are std::string GetPluginsDirectory(); @@ -93,10 +127,6 @@ std::string GetPluginsDirectory(); std::string GetSysDirectory(); #ifdef __APPLE__ - -const char *GetConfigDirectory(); -const char *GetSysConfDirectory(); - std::string GetBundleDirectory(); #endif diff --git a/Source/Core/Common/Src/LogManager.cpp b/Source/Core/Common/Src/LogManager.cpp index 7e9aae01ca..764f761c05 100644 --- a/Source/Core/Common/Src/LogManager.cpp +++ b/Source/Core/Common/Src/LogManager.cpp @@ -19,6 +19,7 @@ #include "ConsoleListener.h" #include "Timer.h" #include "Thread.h" +#include "FileUtil.h" void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char *file, int line, const char* fmt, ...) @@ -79,7 +80,7 @@ LogManager::LogManager() { m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manger", "MemCard Manger"); m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay"); - m_fileLog = new FileLogListener(MAIN_LOG_FILE); + m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX)); m_consoleLog = new ConsoleListener(); for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) { @@ -176,6 +177,10 @@ FileLogListener::FileLogListener(const char *filename) { setEnable(true); } +void FileLogListener::Reload() { + m_logfile = fopen(m_filename, "a+"); +} + FileLogListener::~FileLogListener() { free(m_filename); fclose(m_logfile); diff --git a/Source/Core/Common/Src/LogManager.h b/Source/Core/Common/Src/LogManager.h index 4b5c11415a..07f92640fd 100644 --- a/Source/Core/Common/Src/LogManager.h +++ b/Source/Core/Common/Src/LogManager.h @@ -42,6 +42,8 @@ public: FileLogListener(const char *filename); ~FileLogListener(); + void Reload(); + void Log(LogTypes::LOG_LEVELS, const char *msg); bool isValid() { diff --git a/Source/Core/Common/Src/SysConf.cpp b/Source/Core/Common/Src/SysConf.cpp index 13fb688a0d..3477770816 100644 --- a/Source/Core/Common/Src/SysConf.cpp +++ b/Source/Core/Common/Src/SysConf.cpp @@ -21,13 +21,17 @@ SysConf::SysConf()
: m_IsValid(false)
{
-#if defined(__APPLE__)
- if (LoadFromFile(File::GetSysConfDirectory()))
-#else
- if (LoadFromFile(WII_SYSCONF_FILE))
-#endif
+ if (LoadFromFile(File::GetUserPath(F_WIISYSCONF_IDX))) m_IsValid = true;
}
+ +void SysConf::Reload() +{ + if (m_IsValid) + return; + if (LoadFromFile(File::GetUserPath(F_WIISYSCONF_IDX))) + m_IsValid = true; +} SysConf::~SysConf()
{
diff --git a/Source/Core/Common/Src/SysConf.h b/Source/Core/Common/Src/SysConf.h index 85589d9a70..e3bba9336f 100644 --- a/Source/Core/Common/Src/SysConf.h +++ b/Source/Core/Common/Src/SysConf.h @@ -71,6 +71,8 @@ public: bool IsValid() { return m_IsValid; }
+ void Reload();
+
template<class T>
T GetData(const char* sectionName)
{
|
