mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
create convenience API for documents/caches URLs
This commit is contained in:
parent
815da4e78e
commit
0c31e87483
1 changed files with 27 additions and 0 deletions
27
apple/OmnivoreKit/Sources/Utils/URLExtension.swift
Normal file
27
apple/OmnivoreKit/Sources/Utils/URLExtension.swift
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import Foundation
|
||||
|
||||
public extension URL {
|
||||
// swiftlint:disable:next identifier_name
|
||||
static var om_documentsDirectory: URL {
|
||||
if #unavailable(iOS 16, tvOS 16, macOS 13) {
|
||||
guard let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else {
|
||||
fatalError("Could not determine the user's documents directory")
|
||||
}
|
||||
return url
|
||||
} else {
|
||||
return URL.documentsDirectory
|
||||
}
|
||||
}
|
||||
|
||||
// swiftlint:disable:next identifier_name
|
||||
static var om_cachesDirectory: URL {
|
||||
if #unavailable(iOS 16, tvOS 16, macOS 13) {
|
||||
guard let url = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first else {
|
||||
fatalError("Could not determine the user's caches directory")
|
||||
}
|
||||
return url
|
||||
} else {
|
||||
return URL.cachesDirectory
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue