Module: Fanotify
- Defined in:
- lib/fanotify.rb,
lib/fanotify.rb,
lib/fanotify.rb,
lib/fanotify/mark.rb,
lib/fanotify/event.rb,
lib/fanotify/version.rb,
lib/fanotify/notifier.rb,
lib/fanotify/file_handle.rb
Defined Under Namespace
Classes: Error, Event, FileHandle, Mark, Notifier, PermissionError, UnsupportedError
Constant Summary
collapse
- SystemCallError =
::SystemCallError
- VERSION =
"1.0.0"
- CLASS_FLAGS =
{
notif: FAN_CLASS_NOTIF,
content: FAN_CLASS_CONTENT,
pre_content: FAN_CLASS_PRE_CONTENT
}.freeze
- REPORT_FLAGS =
{
tid: FAN_REPORT_TID,
fid: FAN_REPORT_FID,
dir_fid: FAN_REPORT_DIR_FID,
name: FAN_REPORT_NAME,
dfid_name: FAN_REPORT_DFID_NAME,
target_fid: FAN_REPORT_TARGET_FID | FAN_REPORT_FID,
pidfd: FAN_REPORT_PIDFD
}.freeze
- EVENT_FLAGS =
{
rdonly: O_RDONLY,
wronly: O_WRONLY,
rdwr: O_RDWR,
largefile: O_LARGEFILE,
cloexec: O_CLOEXEC,
nonblock: O_NONBLOCK
}.freeze
- EVENT_MASKS =
{
access: FAN_ACCESS,
modify: FAN_MODIFY,
attrib: FAN_ATTRIB,
close_write: FAN_CLOSE_WRITE,
close_nowrite: FAN_CLOSE_NOWRITE,
open: FAN_OPEN,
moved_from: FAN_MOVED_FROM,
moved_to: FAN_MOVED_TO,
create: FAN_CREATE,
delete: FAN_DELETE,
delete_self: FAN_DELETE_SELF,
move_self: FAN_MOVE_SELF,
open_exec: FAN_OPEN_EXEC,
overflow: FAN_Q_OVERFLOW,
fs_error: FAN_FS_ERROR,
open_perm: FAN_OPEN_PERM,
access_perm: FAN_ACCESS_PERM,
open_exec_perm: FAN_OPEN_EXEC_PERM,
pre_access: FAN_PRE_ACCESS,
event_on_child: FAN_EVENT_ON_CHILD,
rename: FAN_RENAME,
ondir: FAN_ONDIR
}.freeze
Class Method Summary
collapse
Class Method Details
.supported? ⇒ Boolean
26
|
# File 'lib/fanotify.rb', line 26
def supported? = Native.supported?
|
.watch(path, events: %i[create delete modify],, **options, &block) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/fanotify.rb', line 28
def watch(path, events: %i[create delete modify], **options, &block)
return enum_for(__method__, path, events:, **options) unless block
options = {class: :notif, report: %i[fid dfid_name]}.merge(options)
Notifier.open(**options) do |notifier|
notifier.mark(:add, path, events: events + [:event_on_child], only_dir: true)
notifier.each_event(&block)
end
end
|