Revision: 2824
http://skim-app.svn.sourceforge.net/skim-app/?rev=2824&view=rev
Author: hofman
Date: 2007-09-04 05:24:29 -0700 (Tue, 04 Sep 2007)
Log Message:
-----------
Add size of directory contents to file size in info window.
Modified Paths:
--------------
trunk/SKInfoWindowController.m
Modified: trunk/SKInfoWindowController.m
===================================================================
--- trunk/SKInfoWindowController.m 2007-09-04 12:05:34 UTC (rev 2823)
+++ trunk/SKInfoWindowController.m 2007-09-04 12:24:29 UTC (rev 2824)
@@ -89,13 +89,14 @@
FSRef fileRef;
FSCatalogInfo catalogInfo;
unsigned long long size, logicalSize = 0;
- BOOL gotSize = NO;
+ BOOL gotSize = NO, isDir = NO;
NSMutableString *string = [NSMutableString string];
Boolean gotRef = CFURLGetFSRef((CFURLRef)fileURL, &fileRef);
- if (gotRef && noErr == FSGetCatalogInfo(&fileRef, kFSCatInfoDataSizes |
kFSCatInfoRsrcSizes, &catalogInfo, NULL, NULL, NULL)) {
+ if (gotRef && noErr == FSGetCatalogInfo(&fileRef, kFSCatInfoDataSizes |
kFSCatInfoRsrcSizes | kFSCatInfoNodeFlags, &catalogInfo, NULL, NULL, NULL)) {
size = catalogInfo.dataPhysicalSize + catalogInfo.rsrcPhysicalSize;
logicalSize = catalogInfo.dataLogicalSize +
catalogInfo.rsrcLogicalSize;
+ isDir = (catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) != 0;
gotSize = YES;
}
@@ -103,8 +104,22 @@
// this seems to give the logical size
NSDictionary *fileAttrs = [[NSFileManager defaultManager]
fileAttributesAtPath:[fileURL path] traverseLink:NO];
logicalSize = size = [[fileAttrs objectForKey:NSFileSize]
unsignedLongLongValue];
+ isDir = [[fileAttrs fileType] isEqualToString:NSFileTypeDirectory];
}
+ if (isDir) {
+ NSString *path = [fileURL path];
+ NSEnumerator *fileEnum = [[[NSFileManager defaultManager]
subpathsAtPath:path] objectEnumerator];
+ NSString *file;
+ unsigned long long componentSize;
+ unsigned long long logicalComponentSize;
+ while (file = [fileEnum nextObject]) {
+ SKFileSizeStringForFileURL([NSURL fileURLWithPath:[path
stringByAppendingPathComponent:file]], &componentSize, &logicalComponentSize);
+ size += componentSize;
+ logicalSize += logicalComponentSize;
+ }
+ }
+
if (physicalSizePtr)
*physicalSizePtr = size;
if (logicalSizePtr)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit