All Projects → daniel-pedersen → SKQueue

daniel-pedersen / SKQueue

Licence: MIT License
Monitor changes to files and directories using kernel event notifications (kqueue) in Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to SKQueue

Swift-WebP
A thin Swift wrapper of libwebp to make your own encoder/decoder app
Stars: ✭ 135 (+56.98%)
Mutual labels:  swift-wrapper
libapenetwork
Fast cross-platform async network library
Stars: ✭ 17 (-80.23%)
Mutual labels:  kqueue
hev-task-system
A simple, lightweight multi-task system (coroutines) for Unix (Linux/BSD/macOS)
Stars: ✭ 41 (-52.33%)
Mutual labels:  kqueue
UKFileWatcher
A bunch of classes for detecting changes of files and folders. Extracted from UliKit. Home of UKKQueue.
Stars: ✭ 15 (-82.56%)
Mutual labels:  kqueue
verify-changed-files
Github action to verify file changes that occur during the workflow execution.
Stars: ✭ 62 (-27.91%)
Mutual labels:  changed-file
changed-files
Github action to retrieve all (added, copied, modified, deleted, renamed, type changed, unmerged, unknown) files and directories.
Stars: ✭ 733 (+752.33%)
Mutual labels:  changed-file
async
⏱ Promises and reactive-streams in Swift built for high-performance and scalability.
Stars: ✭ 35 (-59.3%)
Mutual labels:  kqueue
netpoll
Package netpoll implements a network poller based on epoll/kqueue.
Stars: ✭ 38 (-55.81%)
Mutual labels:  kqueue
fastsocket
⚠️⚠️⚠️ DEPRECATED
Stars: ✭ 14 (-83.72%)
Mutual labels:  kqueue
Watchexec
Executes commands in response to file modifications
Stars: ✭ 2,651 (+2982.56%)
Mutual labels:  file-watchers
Folden
Cross platform PC application. System wide file watchers handling made simple.
Stars: ✭ 18 (-79.07%)
Mutual labels:  file-watchers
Timliu Ios
iOS开发常用三方库、插件、知名博客等等
Stars: ✭ 10,898 (+12572.09%)
Mutual labels:  swift-wrapper
SwiftyImageIO
A swift wrapper around ImageIO framework
Stars: ✭ 14 (-83.72%)
Mutual labels:  swift-wrapper
brazil-ios-utils
🇧🇷 Utils libraries for specific use cases / business in Brazil
Stars: ✭ 31 (-63.95%)
Mutual labels:  swift-wrapper
Gnet
🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go./ gnet 是一个高性能、轻量级、非阻塞的事件驱动 Go 网络框架。
Stars: ✭ 5,736 (+6569.77%)
Mutual labels:  kqueue
Fswatch
A cross-platform file change monitor with multiple backends: Apple OS X File System Events, *BSD kqueue, Solaris/Illumos File Events Notification, Linux inotify, Microsoft Windows and a stat()-based backend.
Stars: ✭ 3,974 (+4520.93%)
Mutual labels:  kqueue
ev
Lightweight event-loop library based on multiplexing IO
Stars: ✭ 15 (-82.56%)
Mutual labels:  kqueue
xm2cloud term
powerful webssh that developed with django, channels, xterm,ioloop
Stars: ✭ 17 (-80.23%)
Mutual labels:  kqueue

SKQueue

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.

Requirements

  • Swift tools version 4

To build in older environments just replace Package.swift with this file.

Installation

Swift Package Manager

To use SKQueue, add the code below to your dependencies in Package.swift. Then run swift package fetch to fetch SKQueue.

.package(url: "https://github.com/daniel-pedersen/SKQueue.git", from: "1.2.0"),

Usage

To monitor the filesystem with SKQueue, you first need a SKQueueDelegate instance that can accept notifications. Paths to watch can then be added with addPath, as per the example below.

Example

import SKQueue

class SomeClass: SKQueueDelegate {
  func receivedNotification(_ notification: SKQueueNotification, path: String, queue: SKQueue) {
    print("\(notification.toStrings().map { $0.rawValue }) @ \(path)")
  }
}

let delegate = SomeClass()
let queue = 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

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].