summaryrefslogtreecommitdiff
path: root/src/porting.cpp
diff options
context:
space:
mode:
authorNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>2011-06-27 06:56:26 -0700
committerNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>2011-06-27 06:56:26 -0700
commit1c90f9fc2eba43be71f9d49dad75c5d0514d4e50 (patch)
tree63c1116ff43936475874b54d171c7e08556d54ee /src/porting.cpp
parent158b054e72582005d895f1ed0e1cb0c9b22a8e57 (diff)
parent7efe89ff584b2c0338dcede4c1e08504d0158780 (diff)
downloadminetest-1c90f9fc2eba43be71f9d49dad75c5d0514d4e50.tar.gz
minetest-1c90f9fc2eba43be71f9d49dad75c5d0514d4e50.tar.bz2
minetest-1c90f9fc2eba43be71f9d49dad75c5d0514d4e50.zip
Merge pull request #13 from Bahamada/upstream_merge
Upstream merge
Diffstat (limited to 'src/porting.cpp')
-rw-r--r--src/porting.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/porting.cpp b/src/porting.cpp
index 7c7ce48ea..7de042ab5 100644
--- a/src/porting.cpp
+++ b/src/porting.cpp
@@ -27,6 +27,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "config.h"
#include "debug.h"
+#ifdef __APPLE__
+ #include "CoreFoundation/CoreFoundation.h"
+#endif
+
namespace porting
{
@@ -215,9 +219,26 @@ void initializePaths()
#elif defined(__APPLE__)
#include <unistd.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