diff --git a/ChangeLog b/ChangeLog index a0e0067cf..ce0c0b743 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-08-14 Lubos Dolezel + + * Source/NSBundle.m: add NSBundle pathForAuxiliaryExecutable: and + -privateFrameworksPath and their URL counterparts + 2013-08-12 Richard Frith-Macdonald * Headers/Foundation/NSThread.h: diff --git a/Headers/Foundation/NSBundle.h b/Headers/Foundation/NSBundle.h index 480d138cc..90b230337 100644 --- a/Headers/Foundation/NSBundle.h +++ b/Headers/Foundation/NSBundle.h @@ -348,11 +348,22 @@ GS_EXPORT NSString* const NSLoadedClasses; /** Returns the full path to the plug-in subdirectory of the bundle. */ - (NSString *) builtInPlugInsPath; -#if OS_API_VERSION(MAC_OS_X_VERSION_10_2,GS_API_LATEST) +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) /** Returns the full path to the plug-in subdirectory of the bundle. */ - (NSURL *) builtInPlugInsURL; #endif +/** Returns the full path to the private frameworks subdirectory of the bundle. */ +- (NSString *) privateFrameworksPath; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) +/** Returns the full path to the private frameworks subdirectory of the bundle. */ +- (NSURL *) privateFrameworksURL; +#endif + + + + /** Returns the bundle identifier, as defined by the CFBundleIdentifier key in the infoDictionary */ - (NSString *) bundleIdentifier; @@ -454,6 +465,13 @@ GS_EXPORT NSString* const NSLoadedClasses; - (NSURL *) executableURL; #endif +- (NSString *) pathForAuxiliaryExecutable: (NSString *) executableName; + +#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST) +- (NSURL *)URLForAuxiliaryExecutable: (NSString *) executableName; +#endif + + #endif #if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST) diff --git a/Source/NSBundle.m b/Source/NSBundle.m index 6da4f294e..b8f301dc3 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -2742,6 +2742,35 @@ IF_NO_GC( return [NSURL fileURLWithPath: [self executablePath]]; } +- (NSString *) pathForAuxiliaryExecutable: (NSString *) executableName +{ + NSString *version = _frameworkVersion; + + if (!version) + version = @"Current"; + + if (_bundleType == NSBUNDLE_FRAMEWORK) + { +#if !defined(__MINGW__) + return [_path stringByAppendingPathComponent: + [NSString stringWithFormat:@"Versions/%@/%@", + version, executableName]]; +#else + return [_path stringByAppendingPathComponent: executableName]; +#endif + } + else + { + return [_path stringByAppendingPathComponent: executableName]; + } +} + +- (NSURL *) URLForAuxiliaryExecutable: (NSString *) executableName +{ + return [NSURL fileURLWithPath: [self pathForAuxiliaryExecutable: + executableName]]; +} + - (NSString *) resourcePath { NSString *version = _frameworkVersion; @@ -2821,6 +2850,35 @@ IF_NO_GC( return [NSURL fileURLWithPath: [self builtInPlugInsPath]]; } +- (NSString *) privateFrameworksPath +{ + NSString *version = _frameworkVersion; + + if (!version) + version = @"Current"; + + if (_bundleType == NSBUNDLE_FRAMEWORK) + { +#if !defined(__MINGW__) + return [_path stringByAppendingPathComponent: + [NSString stringWithFormat:@"Versions/%@/PrivateFrameworks", + version]]; +#else + return [_path stringByAppendingPathComponent: @"PrivateFrameworks"]; +#endif + } + else + { + return [_path stringByAppendingPathComponent: @"PrivateFrameworks"]; + } +} + +- (NSURL *) privateFrameworksURL +{ + return [NSURL fileURLWithPath: [self privateFrameworksPath]]; +} + + - (NSString*) bundleIdentifier { return [[self infoDictionary] objectForKey: @"CFBundleIdentifier"];