Technical and more info
The values listed in URL Keys are obtained using the following Swift 4.0 code:
let theRes = try url.resourceValues(forKeys: [.fileSizeKey, .totalFileSizeKey])
if let theAll = theRes.totalFileSize {
uTotalSize = theAll
}
if let theData = theRes.fileSize {
uDataSize = theData
}
The value listed in File system for Data is obtained using the following Swift 4.0 code:
let fAttributes = try FileManager.default.attributesOfItem(atPath: url.path)
fmDataSize = fAttributes[FileAttributeKey.size] as! Int
The value listed in File system for Metadata is obtained using the following Swift 4.0 code:
let length = getxattr(fileSystemPath, item, nil, 0, 0, 0)
for each of the xattrs of that file, totalling those values.
The value listed in URL Keys for Metadata is obtained by subtracting the Data value from that of the Total.
The value listed in File system for Total is obtained by adding the Data and Metadata values.
⚠️ Because the URL and FileManager calls for the parent folder of a bundle only return values for that enclosing folder, and not its contents, those are the values displayed by Precize. Thus, it does not show the total size of an RTFD bundle, only that of the bundle folder itself.
Data shown in the other boxes are obtained by listing the whole dictionary returned in the fAttributes value above.
In the Bookmark Resolver, the first set of data are obtained using the key NSURLBookmarkAllPropertiesKey , and the second using NSURLBookmarkDetailedDescription . The Update data button determines the bookmarkDataIsStale setting used in URL.init(resolvingBookmarkData:bookmarkDataIsStale:) which is used to resolve the Bookmark.
➜ details
➜ welcome
Further information about file sizes and xattrs, Bookmarks, inode and other data is on ➜ the Eclectic Light Company blog .
Acknowledgements
Code to generate the FileReferenceURL is adapted from an NSURL extension for Swift 3 written by Frédéric Blondiau.
The method used to generate full Bookmark data in the Resolver was discovered and documented by Michael Lynn, and I am very grateful to him for pointing it out to me.
The Eclectic Light Company – https://eclecticlight.co