diff --git a/platform/osx/dir_access_osx.h b/platform/osx/dir_access_osx.h index c988dfe425e..9a7773f5ee5 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 6e8ceb5e19d..6121e6ccfb7 100644 --- a/platform/osx/dir_access_osx.mm +++ b/platform/osx/dir_access_osx.mm @@ -33,7 +33,8 @@ #include -#include +#include +#include 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