Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
felix91gr committed May 5, 2017
2 parents 0ba41e7 + f23a150 commit 5274b1d
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# FileSystemWatcher

A bridge between Linux's C API [`inotify`](https://linux.die.net/man/7/inotify) and Swift.

## Use cases

For any async file system event monitoring, we gotcha.

## Usage

I made a [demonstration app](https://github.com/felix91gr/fswatcher-usage) of usage of this library.

The most basic form of usage is as follows:

```swift

import FileSystemWatcher

var eventCount : Int

eventCount = 0

func printEvent(event: FileSystemEvent) {
print("Hey! Something happened!!")
// I'd love to use event.name, but I can't figure out yet how to read that from C's API
// That'd be useful for debugging purposes.
// But it's allright as long as you don't need to know the exact description of the ocurring events.
eventCount += 1
}


print("Starting!")

let myWatcher = FileSystemWatcher()

myWatcher.watch(
paths: ["/tmp"],
for: [FileSystemEventType.inAllEvents],
thenInvoke: printEvent)


myWatcher.start()

readLine()

myWatcher.stop()

print("Total number of events: " + String(eventCount))

print("Finished!")

```

0 comments on commit 5274b1d

Please sign in to comment.