ExFSWatch
A file change watcher wrapper based on fs
System Support
Just like fs
- Mac fsevent
- Linux inotify
- Windows inotify-win (untested)
NOTE: On Linux you need to install inotify-tools.
Usage
Put exfswatch
in the deps
and application
part of your mix.exs
defmodule Excellent.Mixfile do
use Mix.Project
def project do
...
end
def application do
[applications: [:exfswatch, :logger]]
end
defp deps do
[
{ :exfswatch, "~> 0.1.0", only: :test },
]
end
...
end
write lib/monitor.ex
defmodule Monitor do
use ExFSWatch, dirs: ["/tmp/fswatch"]
def callback(:stop) do
IO.puts "STOP"
end
def callback(file_path, events) do
IO.inspect {file_path, events}
end
end
Execute in iex
iex > Monitor.start
List Events from Backend
iex > ExFSWatch.known_events
TODO
- GenEvent mode
- Unit Testing