summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpoke1024 <poke1024@gmx.org>2017-08-29 18:22:06 +0200
committerpoke1024 <poke1024@gmx.org>2017-08-29 20:31:03 +0200
commit9d841b5336e2ed65634935aa69b6432bf36cbe1f (patch)
treea6a70306bbe60cb9faa5d1d02dad743fec6998e9
parentc812c176330bfc53a780c0a7c8a9091ddb90f352 (diff)
Implements OS_OSX::get_system_dir()
-rw-r--r--platform/osx/os_osx.h2
-rw-r--r--platform/osx/os_osx.mm40
2 files changed, 42 insertions, 0 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 5bfed1ee50..ebaebd84ce 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -160,6 +160,8 @@ public:
virtual MainLoop *get_main_loop() const;
+ virtual String get_system_dir(SystemDir p_dir) const;
+
virtual bool can_draw() const;
virtual void set_clipboard(const String &p_text);
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index f1260bc088..f502fb9a9c 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1327,6 +1327,46 @@ MainLoop *OS_OSX::get_main_loop() const {
return main_loop;
}
+String OS_OSX::get_system_dir(SystemDir p_dir) const {
+
+ NSSearchPathDirectory id = 0;
+
+ switch (p_dir) {
+ case SYSTEM_DIR_DESKTOP: {
+ id = NSDesktopDirectory;
+ } break;
+ case SYSTEM_DIR_DOCUMENTS: {
+ id = NSDocumentDirectory;
+ } break;
+ case SYSTEM_DIR_DOWNLOADS: {
+ id = NSDownloadsDirectory;
+ } break;
+ case SYSTEM_DIR_MOVIES: {
+ id = NSMoviesDirectory;
+ } break;
+ case SYSTEM_DIR_MUSIC: {
+ id = NSMusicDirectory;
+ } break;
+ case SYSTEM_DIR_PICTURES: {
+ id = NSPicturesDirectory;
+ } break;
+ }
+
+ String ret;
+ if (id) {
+
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(id, NSUserDomainMask, YES);
+ if (paths && [paths count] >= 1) {
+
+ char *utfs = strdup([[paths firstObject] UTF8String]);
+ ret.parse_utf8(utfs);
+ free(utfs);
+ }
+ }
+
+ return ret;
+}
+
bool OS_OSX::can_draw() const {
return true;