filewatch 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/inotify/fd.rb +10 -5
- metadata +1 -1
data/lib/inotify/fd.rb
CHANGED
|
@@ -83,7 +83,8 @@ class Inotify::FD
|
|
|
83
83
|
end
|
|
84
84
|
@watches[watch_descriptor] = {
|
|
85
85
|
:path => path,
|
|
86
|
-
:partial => nil
|
|
86
|
+
:partial => nil,
|
|
87
|
+
:is_directory => File.directory?(path),
|
|
87
88
|
}
|
|
88
89
|
end
|
|
89
90
|
|
|
@@ -127,13 +128,17 @@ class Inotify::FD
|
|
|
127
128
|
# Make any necessary corrections to the event
|
|
128
129
|
private
|
|
129
130
|
def prepare(event)
|
|
130
|
-
|
|
131
|
+
watch = @watches[event[:wd]]
|
|
132
|
+
watchpath = watch[:path]
|
|
131
133
|
if event.name == nil
|
|
132
134
|
# Some events don't have the name at all, so add our own.
|
|
133
135
|
event.name = watchpath
|
|
134
136
|
else
|
|
135
|
-
# Event paths are relative to the watch. Prefix to make
|
|
136
|
-
|
|
137
|
+
# Event paths are relative to the watch, if a directory. Prefix to make
|
|
138
|
+
# the full path.
|
|
139
|
+
if watch[:is_directory]
|
|
140
|
+
event.name = File.join(watchpath, event.name)
|
|
141
|
+
end
|
|
137
142
|
end
|
|
138
143
|
|
|
139
144
|
return event
|
|
@@ -181,7 +186,7 @@ class Inotify::FD
|
|
|
181
186
|
loop do
|
|
182
187
|
event = get
|
|
183
188
|
break if event == nil
|
|
184
|
-
yield
|
|
189
|
+
yield event
|
|
185
190
|
end # loop
|
|
186
191
|
end # def each
|
|
187
192
|
|