Rework path storage, add start screen
This commit is contained in:
@ -2,11 +2,11 @@ import Foundation
|
||||
|
||||
extension URL {
|
||||
|
||||
func ensureParentFolderExistence() throws {
|
||||
try deletingLastPathComponent().ensureFolderExistence()
|
||||
func createParentFolderIfNeeded() throws {
|
||||
try deletingLastPathComponent().createIfNeeded()
|
||||
}
|
||||
|
||||
func ensureFolderExistence() throws {
|
||||
func createIfNeeded() throws {
|
||||
guard !exists else {
|
||||
return
|
||||
}
|
||||
@ -42,7 +42,7 @@ extension URL {
|
||||
if url.exists {
|
||||
try url.delete()
|
||||
}
|
||||
try url.ensureParentFolderExistence()
|
||||
try url.createParentFolderIfNeeded()
|
||||
try FileManager.default.copyItem(at: self, to: url)
|
||||
}
|
||||
|
||||
@ -69,4 +69,14 @@ extension URL {
|
||||
}
|
||||
return URL(string: components.joined(separator: "/"))
|
||||
}
|
||||
|
||||
func containedFiles() throws -> [URL] {
|
||||
try FileManager.default.contentsOfDirectory(at: self, includingPropertiesForKeys: nil, options: [])
|
||||
.filter { !$0.hasDirectoryPath }
|
||||
}
|
||||
|
||||
func containedFileNames() throws -> [String] {
|
||||
try FileManager.default.contentsOfDirectory(atPath: path())
|
||||
.filter { !$0.hasPrefix(".") }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user