diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2019-10-18 15:36:29 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2019-10-18 15:36:29 +0300 |
commit | d8c2e6a31a088507d7828948711a6d58e7c23292 (patch) | |
tree | c3fcc6054edaa1d5c1f4a06903570865d55cdced /platform/osx | |
parent | 119bf237209414a49879fba40459f22315ab1467 (diff) |
[macOS] Fix non-ASCII volume name listing, replace deprecated volume listing API. Remove hidden mount points from the volume list.
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/dir_access_osx.mm | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/platform/osx/dir_access_osx.mm b/platform/osx/dir_access_osx.mm index ada142005b..75f50aaa28 100644 --- a/platform/osx/dir_access_osx.mm +++ b/platform/osx/dir_access_osx.mm @@ -48,18 +48,25 @@ String DirAccessOSX::fix_unicode_name(const char *p_name) const { } int DirAccessOSX::get_drive_count() { - NSArray *vols = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths]; + NSArray *res_keys = [NSArray arrayWithObjects:NSURLVolumeURLKey, NSURLIsSystemImmutableKey, nil]; + NSArray *vols = [[NSFileManager defaultManager] mountedVolumeURLsIncludingResourceValuesForKeys:res_keys options:NSVolumeEnumerationSkipHiddenVolumes]; + return [vols count]; } String DirAccessOSX::get_drive(int p_drive) { - NSArray *vols = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths]; + NSArray *res_keys = [NSArray arrayWithObjects:NSURLVolumeURLKey, NSURLIsSystemImmutableKey, nil]; + NSArray *vols = [[NSFileManager defaultManager] mountedVolumeURLsIncludingResourceValuesForKeys:res_keys options:NSVolumeEnumerationSkipHiddenVolumes]; int count = [vols count]; ERR_FAIL_INDEX_V(p_drive, count, ""); - NSString *path = vols[p_drive]; - return String([path UTF8String]); + String volname; + NSString *path = [vols[p_drive] path]; + + volname.parse_utf8([path UTF8String]); + + return volname; } #endif //posix_enabled |