mirror of
https://github.com/hyperoslo/Cache.git
synced 2026-04-07 19:17:36 +00:00
15 lines
349 B
Swift
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
|
|
}
|
|
}
|
|
}
|