- Notifications
You must be signed in to change notification settings - Fork16
Monitor changes to files and directories using kernel event notifications (kqueue) in Swift
License
daniel-pedersen/SKQueue
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
SKQueue is a Swift libary used to monitor changes to the filesystem.It wraps the part of the kernel event notification interface of libc,kqueue.This means SKQueue has a very small footprint and is highly scalable, just like kqueue.
- Swift tools version 4
To build in older environments just replacePackage.swift withthis file.
To use SKQueue, add the code below to yourdependencies inPackage.swift.Then runswift package fetch to fetch SKQueue.
.package(url:"https://github.com/daniel-pedersen/SKQueue.git", from:"1.2.0"),
To monitor the filesystem withSKQueue, you first need aSKQueueDelegate instance that can accept notifications.Paths to watch can then be added withaddPath, as per the example below.
import SKQueueclassSomeClass:SKQueueDelegate{func receivedNotification(_ notification:SKQueueNotification, path:String, queue:SKQueue){print("\(notification.toStrings().map{ $0.rawValue}) @\(path)")}}letdelegate=SomeClass()letqueue=SKQueue(delegate: delegate)!queue.addPath("/Users/steve/Documents")queue.addPath("/Users/steve/Documents/dog.jpg")
| Action | Sample output |
|---|---|
Add or remove file in/Users/steve/Documents | ["Write"] @ /Users/steve/Documents |
Add or remove directory in/Users/steve/Documents | ["Write", "SizeIncrease"] @ /Users/steve/Documents |
Write to file/Users/steve/Documents/dog.jpg | ["Rename", "SizeIncrease"] @ /Users/steve/Documents/dog.jpg |
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request :D
About
Monitor changes to files and directories using kernel event notifications (kqueue) in Swift
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.