| Last Update: | Thu Aug 09 10:24:35 -0600 2007 |
A class for monitoring events related to files and directories.
win32-event 0.5.0 or later.
The Win32::ChangeNotify class is a subclass of Win32::Ipc.
require 'win32/changenotify'
include Win32
# Indefinitely wait for a change in 'C:\some\path' and any of its
# subdirectories. Print the file and action affected.
filter = ChangeNotify::FILE_NAME | ChangeNotify::DIR_NAME
ChangeNotify.new('C:\some\path\', true, filter) do |cn|
cn.wait{ |events|
events.each{ |event|
p event.file_name
p event.action
}
}
end
ChangeNotify.new(path, recursive, filter, event=nil)
Returns a new ChangeNotify object and places a monitor on +path+. The +path+ argument may be a file or a directory. If +recursive+ is true and +path+ is a directory, then the monitor applies to all subdirectories of +path+.The +filter+ tells the monitor what type of events to watch for. See the 'constants' section for a list of valid filters.
The optional +event+ can be a custom Win32::Event.
ChangeNotify#filter
Returns the numeric values of the filter passed to the constructor. These indicate the sorts of changes to watch for.
ChangeNotify#path
Returns the path name that was passed to the constructor. This is the path/file being watched.
ChangeNotify#recursive?
Returns true or false, depending on the value passed to the constructor. This indicates whether if subdirectories are also being monitored.
ChangeNotify#wait(num_seconds=INFINITE){ |s| … }
Waits up to 'num_seconds' for a notification to occur, or infinitely if no value is specified.If a block is provided, yields an Array of ChangeNotifyStruct's that contain two members - file_name and action. An Array is yielded because more than one event can occur per notification.
VERSION
Returns the current version number of this package as a String.
ATTRIBUTES
Any attribute change
DIR_NAME
Any directory name change
FILE_NAME
Any file name change (creating/deleting/renaming)
LAST_WRITE
Any change to a file's last write time
SECURITY
Any security descriptor change
SIZE
Any change in a file's size
See the README for more information.