OSX fix Dolphin not actually using the Application Support path.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5445 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2010-05-12 04:26:32 +00:00
parent bbc9e8cb71
commit e7099251ce
5 changed files with 31 additions and 71 deletions

View File

@ -57,7 +57,10 @@
#define USERDATA_DIR "User" #define USERDATA_DIR "User"
#define DOLPHIN_DATA_DIR "Dolphin" #define DOLPHIN_DATA_DIR "Dolphin"
#elif defined __APPLE__ #elif defined __APPLE__
#define USERDATA_DIR "User" // On OS X, USERDATA_DIR exists within the .app, but *always* reference
// the copy in Application Support instead! (Copied on first run)
// You can use the File::GetUserPath() util for this
#define USERDATA_DIR "Contents/User"
#define DOLPHIN_DATA_DIR "Library/Application Support/Dolphin" #define DOLPHIN_DATA_DIR "Library/Application Support/Dolphin"
#elif defined __linux__ #elif defined __linux__
#define USERDATA_DIR "user" #define USERDATA_DIR "user"

View File

@ -488,10 +488,10 @@ bool DeleteDirRecursively(const char *directory)
return true; return true;
} }
#ifdef __linux__
//Create directory and copy contents (does not overwrite existing files) //Create directory and copy contents (does not overwrite existing files)
void CopyDir(const char *source_path, const char *dest_path) void CopyDir(const char *source_path, const char *dest_path)
{ {
#ifndef _WIN32
if (!strcmp(source_path, dest_path)) return; if (!strcmp(source_path, dest_path)) return;
if (!File::Exists(source_path)) return; if (!File::Exists(source_path)) return;
if (!File::Exists(dest_path)) File::CreateFullPath(dest_path); if (!File::Exists(dest_path)) File::CreateFullPath(dest_path);
@ -525,8 +525,8 @@ void CopyDir(const char *source_path, const char *dest_path)
else if (!File::Exists(dest)) File::Copy(source, dest); else if (!File::Exists(dest)) File::Copy(source, dest);
} }
closedir(dirp); closedir(dirp);
}
#endif #endif
}
// Returns the current directory // Returns the current directory
std::string GetCurrentDir() std::string GetCurrentDir()
@ -553,7 +553,6 @@ bool SetCurrentDir(const char *_rDirectory)
#if defined(__APPLE__) #if defined(__APPLE__)
std::string GetBundleDirectory() std::string GetBundleDirectory()
{ {
// Plugin path will be Dolphin.app/Contents/PlugIns
CFURLRef BundleRef; CFURLRef BundleRef;
char AppBundlePath[MAXPATHLEN]; char AppBundlePath[MAXPATHLEN];
// Get the main bundle for the app // Get the main bundle for the app
@ -574,7 +573,6 @@ std::string GetBundleDirectory()
} }
#endif #endif
// Returns the path to where the plugins are
std::string GetPluginsDirectory() std::string GetPluginsDirectory()
{ {
std::string pluginsDir; std::string pluginsDir;
@ -596,7 +594,6 @@ std::string GetPluginsDirectory()
return pluginsDir; return pluginsDir;
} }
// Returns the path to where the sys file are
std::string GetSysDirectory() std::string GetSysDirectory()
{ {
std::string sysDir; std::string sysDir;
@ -657,18 +654,13 @@ const char *GetUserPath(int DirIDX)
#ifdef _WIN32 #ifdef _WIN32
// Keep the directory setup the way it was on windows // Keep the directory setup the way it was on windows
snprintf(UserDir, sizeof(UserDir), ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP); snprintf(UserDir, sizeof(UserDir), ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP);
//char homedir[MAX_PATH]; #elif defined (__linux__)
//if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path)))
// return NULL;
#else
if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR))
snprintf(UserDir, sizeof(UserDir), ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP); snprintf(UserDir, sizeof(UserDir), ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP);
else else
{ snprintf(UserDir, sizeof(UserDir), "%s" DIR_SEP DOLPHIN_DATA_DIR DIR_SEP, getenv("HOME"));
char *homedir = getenv("HOME"); #else
if (homedir) snprintf(UserDir, sizeof(UserDir), "%s" DIR_SEP DOLPHIN_DATA_DIR DIR_SEP, getenv("HOME"));
snprintf(UserDir, sizeof(UserDir), "%s" DIR_SEP DOLPHIN_DATA_DIR DIR_SEP, homedir);
}
#endif #endif
INFO_LOG(COMMON, "GetUserPath: Setting user directory to %s:", UserDir); INFO_LOG(COMMON, "GetUserPath: Setting user directory to %s:", UserDir);

View File

@ -111,7 +111,7 @@ bool DeleteDirRecursively(const char *directory);
// Returns the current directory // Returns the current directory
std::string GetCurrentDir(); std::string GetCurrentDir();
//Create directory and copy contents (does not overwrite existing files) // Create directory and copy contents (does not overwrite existing files)
void CopyDir(const char *source_path, const char *dest_path); void CopyDir(const char *source_path, const char *dest_path);
// Set the current directory to given directory // Set the current directory to given directory

View File

@ -18,30 +18,30 @@
#include "../Memmap.h" #include "../Memmap.h"
#include "../EXI_Device.h" #include "../EXI_Device.h"
#include "../EXI_DeviceEthernet.h" #include "../EXI_DeviceEthernet.h"
bool CEXIETHERNET::deactivate() bool CEXIETHERNET::deactivate() {
{
return true; return true;
} }
bool CEXIETHERNET::isActivated() bool CEXIETHERNET::isActivated() {
{
return false; return false;
} }
bool CEXIETHERNET::activate() { bool CEXIETHERNET::activate() {
return false; return false;
} }
bool CEXIETHERNET::CheckRecieved() bool CEXIETHERNET::CheckRecieved() {
{ return false;
} }
bool CEXIETHERNET::resume() { bool CEXIETHERNET::resume() {
return false;
} }
bool CEXIETHERNET::startRecv() { bool CEXIETHERNET::startRecv() {
return false;
} }
bool CEXIETHERNET::sendPacket(u8 *etherpckt, int size) bool CEXIETHERNET::sendPacket(u8 *etherpckt, int size) {
{ return false;
} }
bool CEXIETHERNET::handleRecvdPacket() bool CEXIETHERNET::handleRecvdPacket() {
{ return false;
} }
bool CEXIETHERNET::cbwriteDescriptor(u32 size) { bool CEXIETHERNET::cbwriteDescriptor(u32 size) {
return false;
} }

View File

@ -303,51 +303,16 @@ bool DolphinApp::OnInit()
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
// check to see if ~/Library/Application Support/Dolphin exists; if not, create it const char *AppSupportDir = File::GetUserPath(D_USER_IDX);
char AppSupportDir[MAXPATHLEN];
snprintf(AppSupportDir, sizeof(AppSupportDir), "%s/Library/Application Support", getenv("HOME"));
if (!File::Exists(AppSupportDir) || !File::IsDirectory(AppSupportDir))
PanicAlert("Could not open ~/Library/Application Support");
strlcat(AppSupportDir, "/Dolphin", sizeof(AppSupportDir));
if (!File::Exists(AppSupportDir)) if (!File::Exists(AppSupportDir))
File::CreateDir(AppSupportDir); {
// Fresh run: create Dolphin dir and copy contents of User within the bundle to App Support
if (!File::IsDirectory(AppSupportDir)) File::CopyDir(std::string(File::GetBundleDirectory() + DIR_SEP USERDATA_DIR DIR_SEP).c_str(), AppSupportDir);
}
else if (!File::IsDirectory(AppSupportDir))
PanicAlert("~/Library/Application Support/Dolphin exists, but is not a directory"); PanicAlert("~/Library/Application Support/Dolphin exists, but is not a directory");
chdir(AppSupportDir);
//create all necessary dir in user directory
if (!File::Exists(File::GetUserPath(D_CONFIG_IDX)))
File::CreateDir(File::GetUserPath(D_CONFIG_IDX));
if (!File::Exists(File::GetUserPath(D_GCUSER_IDX)))
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX));
if (!File::Exists(File::GetUserPath(D_WIISYSCONF_IDX)))
File::CreateFullPath(File::GetUserPath(D_WIISYSCONF_IDX));
if (!File::Exists(File::GetUserPath(D_CACHE_IDX)))
File::CreateFullPath(File::GetUserPath(D_CACHE_IDX));
if (!File::Exists(File::GetUserPath(D_DUMPDSP_IDX)))
File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX));
if (!File::Exists(File::GetUserPath(D_DUMPTEXTURES_IDX)))
File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX));
if (!File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX)))
File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX));
if (!File::Exists(File::GetUserPath(D_MAILLOGS_IDX)))
File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX));
if (!File::Exists(File::GetUserPath(D_SCREENSHOTS_IDX)))
File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX));
if (!File::Exists(File::GetUserPath(D_STATESAVES_IDX)))
File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX));
//copy user wii shared2 SYSCONF if not exist
if (!File::Exists(File::GetUserPath(F_WIISYSCONF_IDX)))
File::Copy((File::GetBundleDirectory() + DIR_SEP + "Contents" + DIR_SEP + USERDATA_DIR + DIR_SEP + WII_SYSCONF_DIR + DIR_SEP + WII_SYSCONF).c_str(),
File::GetUserPath(F_WIISYSCONF_IDX));
//TODO : if not exist copy game config dir in user dir and detect the revision to upgrade if necessary
//TODO : if not exist copy maps dir in user dir and detect revision to upgrade if necessary
#if !wxCHECK_VERSION(2, 9, 0) #if !wxCHECK_VERSION(2, 9, 0)
// HACK: Get rid of bogus osx param // HACK: Get rid of bogus osx param
if (argc > 1 && wxString(argv[argc - 1]).StartsWith(_("-psn_"))) { if (argc > 1 && wxString(argv[argc - 1]).StartsWith(_("-psn_"))) {