From: Daniel Berger Date: 2005-02-05T07:25:21+09:00 Subject: Re: win32-changenotify 0.3.0 CT wrote: > > > require "win32/changenotify" > > > include Win32 > > > > > > # Wait for any writes to files in the C:\ drive. > > > filter = ChangeNotify::LAST_WRITE > > > cn = ChangeNotify.new("C:\\",true,filter) > > > cn.wait{ |s| > > > puts "Something changed" > > > puts "File: " + s.file_name > > > puts "Action: " + s.action > > > } > > > > > Okay, I got this working, kinda, after mucking around a bit. What I > want is a daemon-like thingie which will give me notifications when > stuff inside a partocular directory changes. Is it advisable to wrap > the cn.wait call inside an infinite loop, for this? Are there any > consequences for that? > I did something like this: > > while true > cn.wait{ |s| > puts "Something changed" > puts "File: " + s.file_name > puts "Action: " + s.action > } > end > > This does detect file changes, but I donot understand how I get away > without calling cn.reset. Is that invoked when the block is called? > > Thanks! > CT Hi CT, Whoops, this did show up on Google Groups after all. Ugh - still getting used to the new interface. Anyway, you inadvertantly discovered a bug, which I have fixed and uploaded to RubyForge. Please download win32-changenotify 0.3.1 and try again. You should *not* have to wrap the cn.wait call in a "while true" block. It should wait indefinitely if no timeout is specified. Thanks much! Regards, PS - Park is working on win32-changejournal as we speak, which will probably supplant the win32-changenotify package.