mirror of
https://github.com/godotengine/godot.git
synced 2024-11-26 22:23:04 +00:00
Merge pull request #10765 from poke1024/osx-system-dir
Implements OS_OSX::get_system_dir()
This commit is contained in:
commit
433d4ada05
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user