Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
felix91gr authored May 5, 2017
1 parent 4df3e07 commit f23a150
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 f23a150

Please sign in to comment.