From: Jay2 Fernando Date: 2007-01-24T22:04:39+09:00 Subject: Re: inotify subdirectories Martin DeMello wrote: > On 1/24/07, Jay2 Fernando wrote: >> "/tmp/monitor/subdir/test". > You need to maintain a hash of inotify watch descriptors to actual > paths. e.g. > > require 'inotify' > require 'find' > > EVENTS = { 256 => "created", 512 => "deleted", 128 => "moved" } > watches = {} > i = Inotify.new > > Dir["/home/*"].each {|userdir| > begin > wd = i.add_watch(userdir, Inotify::ALL_EVENTS) > watches[wd] = userdir > rescue > puts "Skipping #{userdir}: #{$!}" > end > } > > t = Thread.new { > i.each_event {|ev| > unless ev.name =~ /^\./ > puts "File #{ev.name} #{EVENTS[ev.mask]} in #{watches[ev.wd]}" > end > } > } > > t.join I tried this code but I get the following error: undefined method `wd' for :Inotify::Event (NoMethodError) I got the source code from the URL above. I read the inotify header file and saw the "wd" event. what could be the problem? -- Posted via http://www.ruby-forum.com/.