Files
2020-10-04 15:09:14 +00:00

15 lines
349 B
Swift

import Foundation
extension URL {
/// Returns the file size of the file at the given `URL` in bytes
var fileSize: Int? {
do {
let file = try self.resourceValues(forKeys: [.totalFileAllocatedSizeKey, .fileAllocatedSizeKey])
return file.totalFileAllocatedSize ?? file.fileAllocatedSize
} catch {
return nil
}
}
}