Class: SleepyPenguin::Inotify::Event

Inherits:
Event
  • Object
show all
Defined in:
ext/sleepy_penguin/inotify.c,
ext/sleepy_penguin/inotify.c

Overview

Returned by SleepyPenguin::Inotify#take. It is a Struct with the following elements:

  • wd - watch descriptor (unsigned Integer)

  • mask - mask of events (unsigned Integer)

  • cookie - unique cookie associated related events (for rename)

  • name - optional string name (may be nil)

The mask is a bitmask of the event flags accepted by Inotify#add_watch and may also include the following flags:

  • :IGNORED - watch was removed

  • :ISDIR - event occured on a directory

  • :Q_OVERFLOW - event queue overflowed (wd is -1)

  • :UNMOUNT - filesystem containing watched object was unmounted

Use the Event#events method to get an array of symbols for the matched events.

Instance Method Summary collapse

Instance Method Details

#eventsObject

inotify_event.events => [ :MOVED_TO, … ]

Returns an array of symbolic event names based on the contents of the mask field.



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'ext/sleepy_penguin/inotify.c', line 252

static VALUE events(VALUE self)
{
	long len = RARRAY_LEN(checks);
	long i;
	VALUE sym;
	VALUE rv = rb_ary_new();
	uint32_t mask;
	uint32_t event_mask = NUM2UINT(rb_funcall(self, id_mask, 0));

	for (i = 0; i < len; ) {
		sym = rb_ary_entry(checks, i++);
		mask = NUM2UINT(rb_ary_entry(checks, i++));
		if ((event_mask & mask) == mask)
			rb_ary_push(rv, sym);
	}

	return rv;
}