colibri/Library/Sources/Extensions/URL+Extensions.swift

36 lines
692 B
Swift

import Foundation
extension URL {
// MARK: Initialisers
init(at filePath: String) {
if #available(macOS 13.0, *) {
self = URL(filePath: filePath)
} else {
self = URL(fileURLWithPath: filePath)
}
}
// MARK: Computed
var pathString: String {
if #available(macOS 13.0, *) {
path(percentEncoded: true)
} else {
path
}
}
// MARK: Functions
func appendingPath(_ path: String) -> URL {
if #available(macOS 13.0, *) {
appending(path: path)
} else {
appendingPathComponent(path)
}
}
}