diff options
author | Hein-Pieter van Braam <hp@tmm.cx> | 2017-09-12 17:17:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-12 17:17:55 +0200 |
commit | 647a9141558e0dd618e62b0563dca3363387e897 (patch) | |
tree | 6c74b68614bcd4fe3dcd94a82297d37e203e89d1 /platform | |
parent | 50bc1f29220aafe073256d072e644bdfbcaace83 (diff) | |
parent | fb871b5adae3bada16ce9bb8c661bf959fc66037 (diff) |
Merge pull request #11111 from marcelofg55/drive_funcs_osx
Implemented DirAccess get_drive and get_drive_count for OS X
Diffstat (limited to 'platform')
-rw-r--r-- | platform/osx/dir_access_osx.h | 3 | ||||
-rw-r--r-- | platform/osx/dir_access_osx.mm | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/platform/osx/dir_access_osx.h b/platform/osx/dir_access_osx.h index c988dfe425..9a7773f5ee 100644 --- a/platform/osx/dir_access_osx.h +++ b/platform/osx/dir_access_osx.h @@ -46,6 +46,9 @@ class DirAccessOSX : public DirAccessUnix { protected: virtual String fix_unicode_name(const char *p_name) const; + + virtual int get_drive_count(); + virtual String get_drive(int p_drive); }; #endif //UNIX ENABLED diff --git a/platform/osx/dir_access_osx.mm b/platform/osx/dir_access_osx.mm index 6e8ceb5e19..6121e6ccfb 100644 --- a/platform/osx/dir_access_osx.mm +++ b/platform/osx/dir_access_osx.mm @@ -33,7 +33,8 @@ #include <errno.h> -#include <Foundation/NSString.h> +#include <AppKit/NSWorkspace.h> +#include <Foundation/Foundation.h> String DirAccessOSX::fix_unicode_name(const char *p_name) const { @@ -45,4 +46,19 @@ String DirAccessOSX::fix_unicode_name(const char *p_name) const { return fname; } +int DirAccessOSX::get_drive_count() { + NSArray *vols = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths]; + return [vols count]; +} + +String DirAccessOSX::get_drive(int p_drive) { + NSArray *vols = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths]; + int count = [vols count]; + + ERR_FAIL_INDEX_V(p_drive, count, ""); + + NSString *path = vols[p_drive]; + return String([path UTF8String]); +} + #endif //posix_enabled |