Module: INotify::Native::Flags

Defined in:
lib/vendor/linux/lib/rb-inotify/native/flags.rb

Overview

A module containing all the inotify flags to be passed to INotify::Notifier#watch.

Constant Summary collapse

IN_ACCESS =

File was accessed.

0x00000001
IN_ATTRIB =

Metadata changed.

0x00000004
IN_CLOSE_WRITE =

Writtable file was closed.

0x00000008
IN_MODIFY =

File was modified.

0x00000002
IN_CLOSE_NOWRITE =

Unwrittable file closed.

0x00000010
IN_OPEN =

File was opened.

0x00000020
IN_MOVED_FROM =

File was moved from X.

0x00000040
IN_MOVED_TO =

File was moved to Y.

0x00000080
IN_CREATE =

Subfile was created.

0x00000100
IN_DELETE =

Subfile was deleted.

0x00000200
IN_DELETE_SELF =

Self was deleted.

0x00000400
IN_MOVE_SELF =

Self was moved.

0x00000800
IN_CLOSE =

Close.

(IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
IN_MOVE =

Moves.

(IN_MOVED_FROM | IN_MOVED_TO)
IN_ALL_EVENTS =

All events which a program can wait on.

(IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE |
IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | IN_MOVED_TO | IN_CREATE |
IN_DELETE | IN_DELETE_SELF | IN_MOVE_SELF)
IN_ONLYDIR =

Only watch the path if it is a directory.

0x01000000
IN_DONT_FOLLOW =

Do not follow a sym link.

0x02000000
IN_MASK_ADD =

Add to the mask of an already existing watch.

0x20000000
IN_ONESHOT =

Only send event once.

0x80000000
IN_UNMOUNT =

Backing fs was unmounted.

0x00002000
IN_Q_OVERFLOW =

Event queued overflowed.

0x00004000
IN_IGNORED =

File was ignored.

0x00008000
IN_ISDIR =

Event occurred against dir.

0x40000000

Class Method Summary collapse

Class Method Details

.from_mask(mask) ⇒ Array<Symbol>

Converts a bitmask from the C API into a list of flags.

Parameters:

  • mask (Fixnum)

Returns:

  • (Array<Symbol>)


81
82
83
84
85
86
# File 'lib/vendor/linux/lib/rb-inotify/native/flags.rb', line 81

def self.from_mask(mask)
  constants.map {|c| c.to_s}.select do |c|
    next false unless c =~ /^IN_/
    const_get(c) & mask != 0
  end.map {|c| c.sub("IN_", "").downcase.to_sym} - [:all_events]
end

.to_mask(flags) ⇒ Fixnum

Converts a list of flags to the bitmask that the C API expects.

Parameters:

  • flags (Array<Symbol>)

Returns:

  • (Fixnum)


72
73
74
75
# File 'lib/vendor/linux/lib/rb-inotify/native/flags.rb', line 72

def self.to_mask(flags)
  flags.map {|flag| const_get("IN_#{flag.to_s.upcase}")}.
    inject(0) {|mask, flag| mask | flag}
end