FileManager

extension FileManager

Class for handling the operations with file folders.

Original source code from Haneke

  • Gets the list of files of this the directory.

    Declaration

    Swift

    func enumerateContentsOfDirectory(atPath path: String, orderedByProperty property: String, ascending: Bool, usingBlock block: (URL, Int, inout Bool) -> Void)

    Parameters

    atPath

    path of the directory.

    orderedByProperty

    property to be used for ordeing the contents.

    ascending

    if true it is ordered ascending.

    usingBlock

    block being used.

  • 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, …).
    See more

    Declaration

    Swift

    func allocatedDiskSizeForDirectory(at directoryURL: URL) throws -> UInt64
  • Calculates the actual sum of file sizes

    See more

    Declaration

    Swift

    func fileSizeForDirectory(at directoryURL: URL) throws -> UInt64