[Win32utils-devel] question about changejournal

Berger, Daniel Daniel.Berger at qwest.com
Wed Dec 21 12:07:19 EST 2005

> -----Original Message-----
> From: win32utils-devel-bounces at rubyforge.org 
> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of 
> Stephen Haberman
> Sent: Wednesday, December 21, 2005 12:11 AM
> To: win32utils-devel at rubyforge.org
> Subject: [Win32utils-devel] question about changejournal
> Hi,
> I've got a newbie question--sorry if this is covered 
> elsewhere, I parsed through the archives for awhile and didn't see it.
> I'd like to listen for whenever a file is renamed (e.g. 
> foo.txt -> foo.old) and then magically change it back. This 
> sounds odd, but I'm working with a stubborn application and 
> this will actually make things work nice.
> So, if I do:
> cj = Win32::ChangeJournal.new('c:\\')
> cj.wait do |array| ... end
> Everything works great, except for:
> a) info.file_name isn't the full path--is there a way to tell 
> what directory it is in? E.g. after getting the event, I'd 
> like to go read in the file.

It's not possible for you currently to get the full path name atm.  I'm
not sure if it's possible at all based on the USN_RECORD docs, but I'll
try one or two things.  Heesob, if you have any ideas on this, I'm

> b) cj.wait returns after calling my block--I'd like my block 
> to be called for everything rename event, e.g. just sit there 
> and keep listening. I figure I could just do my processing 
> and then call cj.wait again, but will I miss renames while 
> I'm doing my processing?

You can just use 'while true' at the end of the block, e.g.

cj = ChangeJournal.new("C:\\")

cj.wait{ |array|
   array.each{ |info|
      p info.action
} while true

Voila! Your own changejournal server!

BTW, it's alright that you posted here, but for general help questions I
prefer that folks use the 'help' link on the RubyForge project page.



More information about the win32utils-devel mailing list