mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-16 00:44:51 +02:00
feat: Populate LocalFile with real info
This commit is contained in:
parent
db7a8cef77
commit
fec1ec554b
4 changed files with 38 additions and 13 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue