以下是代码:
require 'rb-inotify'
notifier = INotify::Notifier.new
notifier.watch("/path/to/folder", :moved_to, :create, :attrib, :modify) do |event|
puts "I found #{event.name}!"
end
notifier.run
该文件夹是另一个文件夹的符号链接。我想知道符号链接何时更改。例如,我有/path/to/folder -> /link1
,当它更改为/path/to/folder -> /link2
时,我需要能够分辨。目前我可以更改底层符号链接,不会记录任何事件。这可能使用inotify或ruby包装rb-inotify吗?有没有更好的方法呢?
答案 0 :(得分:1)
您希望传递标记IN_DONT_FOLLOW
以便观看符号链接本身,否则它将会观看/link1
。