|
|
@@ -20,6 +20,17 @@ namespace {
|
|
|
}
|
|
|
|
|
|
namespace env {
|
|
|
+ namespace detail {
|
|
|
+ NSString * bundle_name = nil;
|
|
|
+ void bundle(std::string const & str) {
|
|
|
+ bundle_name = str.empty() ? nil : translate(str);
|
|
|
+ }
|
|
|
+ NSBundle * bundle() {
|
|
|
+ return bundle_name == nil ? [NSBundle mainBundle] :
|
|
|
+ [NSBundle bundleWithIdentifier:bundle_name];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
std::string resource_file(std::string const& path) {
|
|
|
size_t dir_idx = path.find_last_of("/");
|
|
|
size_t ext_idx = path.find_first_of(".");
|
|
|
@@ -27,9 +38,9 @@ namespace env {
|
|
|
std::string name = path.substr(dir_idx + 1, ext_idx - (dir_idx + 1));
|
|
|
std::string type = path.substr(ext_idx + 1);
|
|
|
|
|
|
- NSString* url = [[NSBundle mainBundle] pathForResource:translate(name)
|
|
|
- ofType:translate(type)
|
|
|
- inDirectory:translate(base)];
|
|
|
+ NSString* url = [detail::bundle() pathForResource:translate(name)
|
|
|
+ ofType:translate(type)
|
|
|
+ inDirectory:translate(base)];
|
|
|
|
|
|
char const* abs_path = [url cStringUsingEncoding:encoding];
|
|
|
return abs_path ? std::string(abs_path) : std::string();
|