Giter VIP home page Giter VIP logo

nim-fswatch's Introduction

libfswatch wrapper

Cross-platform filesystem event monitor for Nim.

Wraps the libfswatch library.

badge Nim version tags License

Usage

sudo apt-get install libfswatch11
nimble install fswatch
import times, fswatch

var monitor = newMonitor(latency=0.01)
monitor.add("my-file-path")

proc callback(eg: EventGroup) =
  for e in eg:
    echo e.path, " ", $e.kind, " ", e.time.utc()

monitor.setCallback(callback)

# blocks here
monitor.start()

Contributing

Testing and PRs are welcome.

nim-fswatch's People

Contributors

federicoceratto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mikebelanger

nim-fswatch's Issues

OS X - template/generic instantiation of `setCallback` from here

Hello!

Promising wrappers here! Unfortunately I can't quite get it to run, but maybe I'm doing it wrong.

  • Running Mac OS X (Darwin v. 10.13.6)
  • Installed fswatch with brew, ie) brew install fswatch.
  • Installed this library using nimble, ie) nimble install fswatch.

When I try running the example code, I get an error on line 5, the monitor.setCallback(callback). Its template/generic instantiation of `setCallback` from here. And another, monitor.start() gives the error Error: undeclared identifier: 'data'. I'm guessing the first error is related to the first error though.

Judging from this project's README, this has only been tested on Linux. So I changed the library's libfswatch_fn variable in libsfwatch.nim file to const libfswatch_fn* = "/usr/local/Cellar/fswatch/1.14.0/lib/libfswatch.11.dylib", which is the path to my lib on os x. But I still get the same error after changing this.

If I'm just doing something plain wrong, please let me know and close the issue. Thanks!

Exception with (too many?) folders

Minimal reproduction:

import fswatch

var monitor = newMonitor(latency=0.01)
monitor.set_recursive true
monitor.add("test_files")

proc callback(eg: EventGroup) =
  for e in eg:
    echo "Event: ", e.kind

monitor.setCallback(callback)
monitor.start()

Create a folder containing some folders and run:

mkdir test_files
for i in `seq 10`; do mkdir "test_files/$i"; done
nim c -r test.nim

Yields this result:

Error: unhandled exception: index 101 not in 0 .. 100 [IndexError]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.