mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 15:24:07 +00:00
libobs: Fix disk space reporting for attached network drives on macOS
While the NSURLVolumeAvailableCapacityForOpportunisticUsageKey resource correctly reports available disk space for local volumes (regardless of actual file system used), it does not report actual values for attached network drives. The NSURLVolumeAvailableCapacityKey resource will still report available disk space as expected, so use this value for non-local volumes instead.
This commit is contained in:
parent
59766ee4ff
commit
c83f76db11
|
@ -363,10 +363,21 @@ int64_t os_get_free_space(const char *path)
|
|||
if (path) {
|
||||
NSURL *fileURL = [NSURL fileURLWithPath:@(path)];
|
||||
|
||||
NSDictionary *values = [fileURL resourceValuesForKeys:@[NSURLVolumeAvailableCapacityForOpportunisticUsageKey]
|
||||
error:nil];
|
||||
NSDictionary *values = [fileURL resourceValuesForKeys:@[NSURLVolumeIsLocalKey] error:nil];
|
||||
|
||||
NSNumber *availableSpace = values[NSURLVolumeAvailableCapacityForOpportunisticUsageKey];
|
||||
BOOL isLocalVolume = [values[NSURLVolumeIsLocalKey] boolValue];
|
||||
|
||||
NSURLResourceKey volumeKey;
|
||||
|
||||
if (isLocalVolume) {
|
||||
volumeKey = NSURLVolumeAvailableCapacityForOpportunisticUsageKey;
|
||||
} else {
|
||||
volumeKey = NSURLVolumeAvailableCapacityKey;
|
||||
}
|
||||
|
||||
values = [fileURL resourceValuesForKeys:@[volumeKey] error:nil];
|
||||
|
||||
NSNumber *availableSpace = values[volumeKey];
|
||||
|
||||
if (availableSpace) {
|
||||
return availableSpace.longValue;
|
||||
|
|
Loading…
Reference in a new issue