15 lines
351 B
Swift
15 lines
351 B
Swift
|
|
import Foundation
|
||
|
|
|
||
|
|
extension URL {
|
||
|
|
var fileSize: Int64 {
|
||
|
|
(try? resourceValues(forKeys: [.fileSizeKey]).fileSize)
|
||
|
|
.flatMap { Int64($0) } ?? 0
|
||
|
|
}
|
||
|
|
|
||
|
|
var sanitizedFilename: String {
|
||
|
|
lastPathComponent
|
||
|
|
.components(separatedBy: .init(charactersIn: "/\\:*?\"<>|"))
|
||
|
|
.joined(separator: "_")
|
||
|
|
}
|
||
|
|
}
|