mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Merge pull request #11111 from marcelofg55/drive_funcs_osx
Implemented DirAccess get_drive and get_drive_count for OS X
This commit is contained in:
commit
647a914155
@ -46,6 +46,9 @@
|
|||||||
class DirAccessOSX : public DirAccessUnix {
|
class DirAccessOSX : public DirAccessUnix {
|
||||||
protected:
|
protected:
|
||||||
virtual String fix_unicode_name(const char *p_name) const;
|
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
|
#endif //UNIX ENABLED
|
||||||
|
@ -33,7 +33,8 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#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 {
|
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;
|
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
|
#endif //posix_enabled
|
||||||
|
Loading…
Reference in New Issue
Block a user