Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [ANN] win32-changenotify 0.3.0

Reply
Thread Tools

[ANN] win32-changenotify 0.3.0

 
 
Daniel Berger
Guest
Posts: n/a
 
      01-25-2005
Hi all,

The Win32Utils Team is proud to annouce win32-changenotify 0.3.0

What is it?
===========
An interface for monitoring file and/or directory changes on the Win32
platform.

Synopsis
========
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
}

What's new?
===========
The interface has been altered so that ChangeNotify#wait will yield a
structure (if a block is given) that provides more detailed information
as to what, exactly, the changes were.

See the documentation for more details.

Where is it?
============
You can find it on the RAA or on the RubyForge project page at
http://www.rubyforge.org/projects/win32utils.

Also, I have release a standalone .so file that you can download from
the RubyForge project page if you don't happen to have a compiler. Be
sure to put it under a "win32" toplevel directory somewhere in your
library path.

Many thanks go to Park Heesob (again) for helping me with some sticky C
issues.

Future Plans
============
We are planning on an interface for Change Journals which will either
supplant or replace this package. Keep an eye out.
Enjoy!

The Win32Utils Team

 
Reply With Quote
 
 
 
 
CT
Guest
Posts: n/a
 
      02-04-2005
Thanks for the great work with win32!


On Wed, 26 Jan 2005 08:20:51 +0900, Daniel Berger <(E-Mail Removed)> 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
> }
>


I tried to run this script, after installing everything. The script
terminates, I make changes to files in C:\\, and nothing happens. What
am I doing wrong? Is there any other doc/sample for
win32-changenotify?

Thanks in advance!
CT


 
Reply With Quote
 
 
 
 
CT
Guest
Posts: n/a
 
      02-04-2005
> > 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


 
Reply With Quote
 
Daniel Berger
Guest
Posts: n/a
 
      02-04-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments