Rework path storage, add start screen

This commit is contained in:
Christoph Hagen
2024-12-17 23:05:45 +01:00
parent 849585acc7
commit 9a53e020a7
21 changed files with 408 additions and 229 deletions

View File

@ -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(".") }
}
}