[ANN] win32-changenotify 0.3.0

Discussion in 'Ruby' started by Daniel Berger, Jan 25, 2005.

  1. 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
    Daniel Berger, Jan 25, 2005
    #1
    1. Advertising

  2. Daniel Berger

    CT Guest

    Thanks for the great work with win32!


    On Wed, 26 Jan 2005 08:20:51 +0900, Daniel Berger <> 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
    CT, Feb 4, 2005
    #2
    1. Advertising

  3. Daniel Berger

    CT Guest

    > > 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
    CT, Feb 4, 2005
    #3
  4. 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.
    Daniel Berger, Feb 4, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Berger

    [ANN] win32-changenotify

    Daniel Berger, May 8, 2004, in forum: Ruby
    Replies:
    0
    Views:
    89
    Daniel Berger
    May 8, 2004
  2. Replies:
    7
    Views:
    96
    Daniel Berger
    Dec 15, 2006
  3. Martin DeMello

    win32::changenotify and multiple events

    Martin DeMello, Feb 28, 2007, in forum: Ruby
    Replies:
    0
    Views:
    96
    Martin DeMello
    Feb 28, 2007
  4. perl coder
    Replies:
    0
    Views:
    125
    perl coder
    Feb 16, 2004
  5. Thomas Kratz

    Leak in Win32::ChangeNotify?

    Thomas Kratz, Dec 28, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    161
    Matt Garrish
    Dec 29, 2004
Loading...

Share This Page