Implemented the "currentFolder" property for the FileService service in the Library target.

This commit is contained in:
2025-01-11 01:26:26 +01:00
parent ecbec1f4c8
commit 6938b358e1
3 changed files with 58 additions and 0 deletions
@@ -0,0 +1,9 @@
import Foundation
protocol FileServicing {
// MARK: Properties
var currentFolder: URL { get async }
}
@@ -0,0 +1,27 @@
import Foundation
struct FileService: FileServicing {
// MARK: Properties
private let fileManager: FileManager
// MARK: Initialisers
init(fileManager: FileManager = .default) {
self.fileManager = fileManager
}
// MARK: Computed
var currentFolder: URL {
get async {
if #available(macOS 13.0, *) {
.init(filePath: fileManager.currentDirectoryPath)
} else {
.init(fileURLWithPath: fileManager.currentDirectoryPath)
}
}
}
}