allocatedDiskSizeForDirectory(at:)
func allocatedDiskSizeForDirectory(at directoryURL: URL) throws -> UInt64
Calculate the allocated size of a directory and all its contents on the volume.
As there’s no simple way to get this information from the file system the method has to crawl the entire hierarchy, accumulating the overall sum on the way. The resulting value is roughly equivalent with the amount of bytes that would become available on the volume if the directory would be deleted.
Note
There are a couple of oddities that are not taken into account (like symbolic links, meta data of directories, hard links, …).-
Error handler in case there is a problem when getting the information from the disk
Declaration
Swift
func errorHandler(_: URL, error: Error) -> Bool