Files
Kisani/Shared/Extensions/URL+.swift

15 lines
351 B
Swift
Raw Permalink Normal View History

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: "_")
}
}