gmethvin / directory-watcher

A cross-platform Java recursive directory watcher, with a JNA macOS watcher and Scala better-files integration
Apache License 2.0
265 stars 34 forks source link

Add better-files integration #4

Closed gmethvin closed 6 years ago

gmethvin commented 6 years ago

Adds another module with an implementation of the better-files File.Monitor. It can be used very much like the existing better-files API and is designed to be used with better-files. For example:

import better.files._
import io.methvin.better.files._

val directory = File("directory/to/watch/")
val watcher = new RecursiveFileMonitor(directory) {
  override def onCreate(file: File, count: Int) = println(s"$file got created")
  override def onModify(file: File, count: Int) = println(s"$file got modified $count times")
  override def onDelete(file: File, count: Int) = println(s"$file got deleted")
}
watcher.start()