Important
This Swift package is currently in an early state and not ready to use.
This will change when v.1.0.0 is released.
Note
This package uses semantic versioning.
import Foundation
import Swift_Hotfolder
@main
struct HotfolderApp {
static func main() async {
print("Welcome to Swift Hotfolder🔥")
guard let hotfolder = Hotfolder(atPath: "/Users/USER_NAME/Desktop/My_firts_Hotfolder") else {
print("Hotfolder can't be created.")
return
}
let modifyCancellable = hotfolder.modifySubject.sink { modifiedUrl in
print("Modified: \(modifiedUrl.path(percentEncoded: false))")
}
let deleteCancellable = hotfolder.deleteSubject.sink { deletedUrl in
print("Deleted: \(deletedUrl.path(percentEncoded: false))")
}
let createCancellable = hotfolder.createSubject.sink { createdUrl in
print("Created: \(createdUrl.path(percentEncoded: false))")
}
let watcher = HotfolderWatcher.shared
await watcher.add(hotfolder)
// Start watching
do {
try await watcher.startWatching()
} catch {
print("Error in 'HotfolderWatcher.startWatching': \(error)")
}
try? await Task.sleep(for: .seconds(120))
}
}