feat: Populate LocalFile with real info

This commit is contained in:
ronaldheft committed 2022-07-30 16:22:41 -04:00
1 parent db7a8cef77
commit fec1ec554b
4 files changed
+38 -13

No files matched your search

+23
View File
@@ -42,3 +42,26 @@ extension DispatchQueue {
}
}
}
extension URL {
var attributes: [FileAttributeKey : Any]? {
do {
return try FileManager.default.attributesOfItem(atPath: path)
} catch let error as NSError {
print("FileAttribute error: \(error)")
}
return nil
}
var fileSize: Int64 {
return attributes?[.size] as? Int64 ?? Int64(0)
}
var fileSizeString: String {
return ByteCountFormatter.string(fromByteCount: Int64(fileSize), countStyle: .file)
}
var creationDate: Date? {
return attributes?[.creationDate] as? Date
}
}