> -----Original Message-----
> From: win32utils-devel-bounces@rubyforge.org
> [mailto:win32utils-devel-bounces@rubyforge.org] On Behalf Of
> Zach Dennis
> Sent: Wednesday, April 20, 2005 11:53 PM
> To: Development and ideas for win32utils projects
> Subject: Re: [Win32utils-devel] win32-changejournal modification
>
>
> Daniel Berger wrote:
> > Hi all,
> >
> > Should we make the same change for win32-changejournal
> > that we made for win32-changenotify (i.e yield an
> > array of structs rather than a single struct)?
> >
> > Any objections?
>
> No objections....but i can''t say i know what either of those
> are off the
> top of my head...
>
> Zach
They''re directory/file monitors. For example:
flags = ChangeNotify::FILE_NAME | ChangeNotify::DIR_NAME
flags |= ChangeNotify::LAST_WRITE
cn = ChangeNotify.new("c:\\",false,flags)
# Wait up to 5 minutes for a notification
rv = cn.wait(300){ |arr|
arr.each { |s|
puts "Something changed"
puts "File: " + s.file_name
puts "Action: " + s.action
}
}
Every time there''s a change to a file or directory under C:\ a
notification is sent. In some cases, multiple notifications can occur
on a single event, which is why we altered it to yield an array of
structs, rather than a single struct. Using the above example, if I
change "C:\err.txt" to "C:\foo.txt" I get this:
Something changed
File: err.txt
Action: renamed old name
Something changed
File: foo.txt
Action: renamed new name
You can see there we actually got 2 notifications. Previously, you
would only have been able to get one.
HTH.
Dan