Allow launching through a symlink. It doesn't work quite like normal applications. Menus don't show up, it doesn't really seem to know where it is.
Still, most people just would use the Finder and never encounter this behavior.
This commit is contained in:
@@ -221,7 +221,12 @@ static void ChangeToDirOfExecutable( const RString &argv0 )
|
|||||||
#if defined(_WINDOWS)
|
#if defined(_WINDOWS)
|
||||||
chdir( RageFileManagerUtil::sDirOfExecutable + "/.." );
|
chdir( RageFileManagerUtil::sDirOfExecutable + "/.." );
|
||||||
#elif defined(MACOSX)
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,10 +83,15 @@ void ArchHooks_darwin::Init()
|
|||||||
|
|
||||||
CFBundleRef bundle = CFBundleGetMainBundle();
|
CFBundleRef bundle = CFBundleGetMainBundle();
|
||||||
CFStringRef appID = CFBundleGetIdentifier( bundle );
|
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) );
|
CFStringRef version = CFStringRef( CFBundleGetValueForInfoDictionaryKey(bundle, kCFBundleVersionKey) );
|
||||||
|
CFPropertyListRef old = CFPreferencesCopyAppValue( key, appID );
|
||||||
CFURLRef path = CFBundleCopyBundleURL( bundle );
|
CFURLRef path = CFBundleCopyBundleURL( bundle );
|
||||||
CFPropertyListRef value = CFURLCopyFileSystemPath( path, kCFURLPOSIXPathStyle );
|
CFPropertyListRef value = CFURLCopyFileSystemPath( path, kCFURLPOSIXPathStyle );
|
||||||
CFPropertyListRef old = CFPreferencesCopyAppValue( key, appID );
|
|
||||||
CFMutableDictionaryRef newDict = NULL;
|
CFMutableDictionaryRef newDict = NULL;
|
||||||
|
|
||||||
if( old && CFGetTypeID(old) != CFDictionaryGetTypeID() )
|
if( old && CFGetTypeID(old) != CFDictionaryGetTypeID() )
|
||||||
@@ -437,16 +442,9 @@ static void PathForFolderType( char dir[PATH_MAX], OSType folderType )
|
|||||||
|
|
||||||
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
||||||
{
|
{
|
||||||
CFBundleRef bundle = CFBundleGetMainBundle();
|
|
||||||
CFURLRef bundleURL = CFBundleCopyBundleURL( bundle );
|
|
||||||
CFURLRef dirURL = CFURLCreateCopyDeletingLastPathComponent( kCFAllocatorDefault, bundleURL );
|
|
||||||
char dir[PATH_MAX];
|
char dir[PATH_MAX];
|
||||||
|
|
||||||
if( !CFURLGetFileSystemRepresentation(dirURL, true, (UInt8 *)dir, sizeof(dir)) )
|
FILEMAN->Mount( "dir", sDirOfExecutable, "/" );
|
||||||
FAIL_M( "CFURLGetFileSystemRepresentation() failed." );
|
|
||||||
CFRelease( bundleURL );
|
|
||||||
CFRelease( dirURL );
|
|
||||||
FILEMAN->Mount( "dir", dir, "/" );
|
|
||||||
|
|
||||||
// /Save -> ~/Library/Application Support/PRODUCT_ID
|
// /Save -> ~/Library/Application Support/PRODUCT_ID
|
||||||
PathForFolderType( dir, kPreferencesFolderType );
|
PathForFolderType( dir, kPreferencesFolderType );
|
||||||
|
|||||||
Reference in New Issue
Block a user