Directory monitoring on NTFS

Hello all,

I am in a situation where I need to monitor a directory for changes
(Basically only when files are created in it) on Windows (NTFS
filesystem) from a long running jruby script.

After a bit of searching I found
https://github.com/djberg96/win32-changejournal however this uses a C
Extension and requires the win32 gem etc.

Since I am going to be using JRuby I thought there must be a java based
solution and it looks like Java 7 got a “WatchService” interface.

This looks good but before I delve into the “J” in JRuby I just wanted
to see if anyone had already faced this question and had any other ideas

cheers

Jeff

I would go with the Java 7 solution over a native C extension. Using
Java
directly from JRuby is usually a smoother path than working with C
extensions, plus if you use the Java solution your code should work on
any platform and wouldn’t be a Windows specific solution in case you
ever
needed something different in the future.

Joe

I’m using the Java 7 watch service for a small little app at work and it
really didn’t take too long to get it working. These blog posts summed
up
what it does pretty simply:

http://java.dzone.com/articles/introducing-nio2-jsr-203-part-2
http://java.dzone.com/news/how-watch-file-system-changes

I know that Headius mentioned JNotify some time ago as an option, and if
you don’t want to use Java 7 for it, this is probably another good
option
that you might be able to: http://jnotify.sourceforge.net/


and with a little bit of googling, someone might have already wrapped it
in
JRuby: https://github.com/netzpirat/jruby-notify

-Nick K.

Thanks very much all.

Easy to find when you know the correct search terms.

cheers

Jeff

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs