Skip to content

Monitor your directories asyncronusly.

License

Notifications You must be signed in to change notification settings

CodebyCR/Swift-Hotfolder

Repository files navigation

Swift Hotfolder

Logo Logo Logo Logo Logo
Monitor your directories asyncronusly.

#ConstributersWelcome❤️

Note

This package uses semantic versioning.

Example Usage

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))
    }
}

About

Monitor your directories asyncronusly.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages