Revision: 12102
http://sourceforge.net/p/skim-app/code/12102
Author: hofman
Date: 2021-01-03 10:01:57 +0000 (Sun, 03 Jan 2021)
Log Message:
-----------
Get multiple file URL resources at once
Modified Paths:
--------------
trunk/SKInfoWindowController.m
Modified: trunk/SKInfoWindowController.m
===================================================================
--- trunk/SKInfoWindowController.m 2021-01-01 13:52:47 UTC (rev 12101)
+++ trunk/SKInfoWindowController.m 2021-01-03 10:01:57 UTC (rev 12102)
@@ -194,22 +194,18 @@
unsigned long long size, logicalSize = 0;
BOOL isDir = NO;
NSMutableString *string = [NSMutableString string];
- NSNumber *number;
-
- if ([fileURL getResourceValue:&number forKey:NSURLTotalFileSizeKey
error:NULL])
- logicalSize = [number unsignedLongLongValue];
- if ([fileURL getResourceValue:&number
forKey:NSURLTotalFileAllocatedSizeKey error:NULL])
- size = [number unsignedLongLongValue];
- if ([fileURL getResourceValue:&number forKey:NSURLIsDirectoryKey
error:NULL])
- isDir = [number boolValue];
+ NSDictionary *values = [fileURL resourceValuesForKeys:[NSArray
arrayWithObjects:NSURLTotalFileSizeKey, NSURLTotalFileAllocatedSizeKey,
NSURLIsDirectoryKey, nil] error:NULL];
+ logicalSize = [[values objectForKey:NSURLTotalFileSizeKey]
unsignedLongLongValue];
+ size = [[values objectForKey:NSURLTotalFileAllocatedSizeKey]
unsignedLongLongValue];
+ isDir = [[values objectForKey:NSURLIsDirectoryKey] boolValue];
+
if (isDir) {
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager]
enumeratorAtURL:fileURL includingPropertiesForKeys:[NSArray
arrayWithObjects:NSURLTotalFileSizeKey, NSURLTotalFileAllocatedSizeKey, nil]
options:0 errorHandler:NULL];
for (NSURL *subFileURL in dirEnum) {
- if ([subFileURL getResourceValue:&number
forKey:NSURLTotalFileSizeKey error:NULL])
- logicalSize += [number unsignedLongLongValue];
- if ([subFileURL getResourceValue:&number
forKey:NSURLTotalFileAllocatedSizeKey error:NULL])
- size += [number unsignedLongLongValue];
+ values = [subFileURL resourceValuesForKeys:[NSArray
arrayWithObjects:NSURLTotalFileSizeKey, NSURLTotalFileAllocatedSizeKey,
NSURLIsDirectoryKey, nil] error:NULL];
+ logicalSize += [[values objectForKey:NSURLTotalFileSizeKey]
unsignedLongLongValue];
+ size += [[values objectForKey:NSURLTotalFileAllocatedSizeKey]
unsignedLongLongValue];
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit