blob: 424e35f840c675d3f51374715df126ae62028bbd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;
}
|