Swift-Hotfolder

1.0.0

Monitor your directories asyncronusly.
CodebyCR/Swift-Hotfolder

What's New

1.0.0

2024-09-26T14:55:47Z

What's Changed

New Contributors

Full Changelog: 0.6.0...1.0.0

Swift Hotfolder

Logo Logo Logo Logo Logo
Monitor your directories asyncronusly.

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.

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

Description

  • Swift Tools 5.10.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon May 12 2025 17:15:47 GMT-0900 (Hawaii-Aleutian Daylight Time)