summaryrefslogtreecommitdiff
path: root/src/bundle.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/bundle.mm')
-rw-r--r--src/bundle.mm36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/bundle.mm b/src/bundle.mm
new file mode 100644
index 00000000..424e35f8
--- /dev/null
+++ b/src/bundle.mm
@@ -0,0 +1,36 @@
+//
+// bundle.m
+// themanaworld
+//
+// Created by David Athay on 1/27/11.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "bundle.h"
+#import <Cocoa/Cocoa.h>
+
+std::string getBundleResourcesPath()
+{
+ std::string resPath;
+ NSBundle *mainBundle;
+
+ // Get the main bundle for the app.
+ mainBundle = [NSBundle mainBundle];
+
+ NSString *bundlePath = [mainBundle bundlePath];
+ NSArray *bundlePathArray = [[NSFileManager defaultManager] directoryContentsAtPath:bundlePath];
+ // check it contains the right directories
+ if ((nil != bundlePathArray) && ([bundlePathArray containsObject:@"Contents"]))
+ {
+ NSString *contentsPath = [bundlePath stringByAppendingPathComponent:@"Contents"];
+ NSArray *contentsPathArray = [[NSFileManager defaultManager] directoryContentsAtPath:contentsPath];
+ if ((nil != contentsPath) && ([contentsPathArray containsObject:@"MacOS"]) && ([contentsPathArray containsObject:@"Resources"]))
+ {
+ // get the final path of the resources
+ NSString *finalResourcesPath = [contentsPath stringByAppendingPathComponent:@"Resources"];
+ resPath = [finalResourcesPath UTF8String];
+ }
+ }
+
+ return resPath;
+} \ No newline at end of file