diff --git a/stepmania/src/RageFileManager.cpp b/stepmania/src/RageFileManager.cpp index b4bbe0666b..a1388b4db5 100644 --- a/stepmania/src/RageFileManager.cpp +++ b/stepmania/src/RageFileManager.cpp @@ -221,7 +221,12 @@ static void ChangeToDirOfExecutable( const RString &argv0 ) #if defined(_WINDOWS) chdir( RageFileManagerUtil::sDirOfExecutable + "/.." ); #elif defined(MACOSX) - chdir( RageFileManagerUtil::sDirOfExecutable + "/../../.." ); + /* If the basename is not MacOS, then we've likely been launched via the command line + * through a symlink. Assume this is the case and change to the dir of the symlink. */ + puts( RageFileManagerUtil::sDirOfExecutable ); + if( Basename(RageFileManagerUtil::sDirOfExecutable) == "MacOS" ) + CollapsePath( RageFileManagerUtil::sDirOfExecutable += "/../../.." ); + chdir( RageFileManagerUtil::sDirOfExecutable ); #endif } diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_darwin.cpp b/stepmania/src/arch/ArchHooks/ArchHooks_darwin.cpp index 08143607e5..dcfbdaa01f 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_darwin.cpp +++ b/stepmania/src/arch/ArchHooks/ArchHooks_darwin.cpp @@ -83,10 +83,15 @@ void ArchHooks_darwin::Init() CFBundleRef bundle = CFBundleGetMainBundle(); CFStringRef appID = CFBundleGetIdentifier( bundle ); + if( appID == NULL ) + { + // We were probably launched through a symlink. Don't bother hunting down the real path. + return; + } CFStringRef version = CFStringRef( CFBundleGetValueForInfoDictionaryKey(bundle, kCFBundleVersionKey) ); + CFPropertyListRef old = CFPreferencesCopyAppValue( key, appID ); CFURLRef path = CFBundleCopyBundleURL( bundle ); CFPropertyListRef value = CFURLCopyFileSystemPath( path, kCFURLPOSIXPathStyle ); - CFPropertyListRef old = CFPreferencesCopyAppValue( key, appID ); CFMutableDictionaryRef newDict = NULL; if( old && CFGetTypeID(old) != CFDictionaryGetTypeID() ) @@ -437,16 +442,9 @@ static void PathForFolderType( char dir[PATH_MAX], OSType folderType ) void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable ) { - CFBundleRef bundle = CFBundleGetMainBundle(); - CFURLRef bundleURL = CFBundleCopyBundleURL( bundle ); - CFURLRef dirURL = CFURLCreateCopyDeletingLastPathComponent( kCFAllocatorDefault, bundleURL ); char dir[PATH_MAX]; - if( !CFURLGetFileSystemRepresentation(dirURL, true, (UInt8 *)dir, sizeof(dir)) ) - FAIL_M( "CFURLGetFileSystemRepresentation() failed." ); - CFRelease( bundleURL ); - CFRelease( dirURL ); - FILEMAN->Mount( "dir", dir, "/" ); + FILEMAN->Mount( "dir", sDirOfExecutable, "/" ); // /Save -> ~/Library/Application Support/PRODUCT_ID PathForFolderType( dir, kPreferencesFolderType );