diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-06-18 18:44:01 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-06-18 18:44:01 +0300 |
commit | 5d1ae85ab9829ab38b96277a8cd63e4539774e06 (patch) | |
tree | 3ad291a2a650da85750ae894f8300cb605172d11 /src/porting.cpp | |
parent | 13f469073e58d4626dde9ff33cbf6d2125daca01 (diff) | |
download | minetest-5d1ae85ab9829ab38b96277a8cd63e4539774e06.tar.gz minetest-5d1ae85ab9829ab38b96277a8cd63e4539774e06.tar.bz2 minetest-5d1ae85ab9829ab38b96277a8cd63e4539774e06.zip |
Hand-picked Mac OSX cursor and bundle path fixes from https://bitbucket.org/toabi/minetest-mac
Diffstat (limited to 'src/porting.cpp')
-rw-r--r-- | src/porting.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/porting.cpp b/src/porting.cpp index 7c7ce48ea..cce461be8 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -214,10 +214,28 @@ void initializePaths() */ #elif defined(__APPLE__) #include <unistd.h> - + #include "CoreFoundation/CoreFoundation.h" + + // Code based on + // http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c + CFBundleRef main_bundle = CFBundleGetMainBundle(); + CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle); + char path[PATH_MAX]; + if(CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX)) + { + dstream<<"Bundle resource path: "<<path<<std::endl; + //chdir(path); + path_data = std::string(path) + "/data"; + } + else + { + // error! + dstream<<"WARNING: Could not determine bundle resource path"<<std::endl; + } + CFRelease(resources_url); + path_userdata = std::string(getenv("HOME")) + "/Library/Application Support/" + APPNAME; - path_data = std::string("minetest-mac.app/Contents/Resources/data/"); - + #endif #endif // RUN_IN_PLACE |