diff options
Diffstat (limited to 'base/mac')
-rw-r--r-- | base/mac/foundation_util.h | 3 | ||||
-rw-r--r-- | base/mac/foundation_util.mm | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/base/mac/foundation_util.h b/base/mac/foundation_util.h index a94cf95..a7c525a 100644 --- a/base/mac/foundation_util.h +++ b/base/mac/foundation_util.h @@ -45,6 +45,9 @@ bool IsBackgroundOnlyProcess(); NSBundle* MainAppBundle(); FilePath MainAppBundlePath(); +// Returns the path to a resource within the MainAppBundle. +FilePath PathForMainAppBundleResource(CFStringRef resourceName); + // Set the bundle that MainAppBundle will return, overriding the default value // (Restore the default by calling SetOverrideAppBundle(nil)). void SetOverrideAppBundle(NSBundle* bundle); diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm index ad8a247..151d82f 100644 --- a/base/mac/foundation_util.mm +++ b/base/mac/foundation_util.mm @@ -80,6 +80,15 @@ FilePath MainAppBundlePath() { return FilePath([[bundle bundlePath] fileSystemRepresentation]); } +FilePath PathForMainAppBundleResource(CFStringRef resourceName) { + NSBundle* bundle = MainAppBundle(); + NSString* resourcePath = [bundle pathForResource:(NSString*)resourceName + ofType:nil]; + if (!resourcePath) + return FilePath(); + return FilePath([resourcePath fileSystemRepresentation]); +} + void SetOverrideAppBundle(NSBundle* bundle) { if (bundle != g_override_app_bundle) { [g_override_app_bundle release]; |