Sha256: 2f607b0b348fd45e0d9ac726030badc385aac72240f268047ba1f7a84d6241aa

Contents?: true

Size: 807 Bytes

Versions: 13

Compression:

Stored size: 807 Bytes

Contents

module Libuv
    class FSEvent < Handle


        define_callback function: :on_fs_event, params: [:pointer, :string, :int, :int]


        EVENTS = {1 => :rename, 2 => :change}.freeze


        def initialize(thread, path)
            @loop = thread

            fs_event_ptr = ::Libuv::Ext.allocate_handle_fs_event
            error = check_result ::Libuv::Ext.fs_event_init(thread.handle, fs_event_ptr, path, callback(:on_fs_event, fs_event_ptr.address), 0)

            super(fs_event_ptr, error)
        end


        private


        def on_fs_event(handle, filename, events, status)
            e = check_result(status)

            if e
                reject(e)
            else
                defer.notify(filename, EVENTS[events])   # notify of a change
            end
        end
    end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
libuv-2.0.12 lib/libuv/fs_event.rb
libuv-2.0.11 lib/libuv/fs_event.rb
libuv-2.0.10 lib/libuv/fs_event.rb
libuv-2.0.9 lib/libuv/fs_event.rb
libuv-2.0.8 lib/libuv/fs_event.rb
libuv-2.0.6 lib/libuv/fs_event.rb
libuv-2.0.5 lib/libuv/fs_event.rb
libuv-2.0.4 lib/libuv/fs_event.rb
libuv-2.0.3 lib/libuv/fs_event.rb
libuv-2.0.2 lib/libuv/fs_event.rb
libuv-2.0.1 lib/libuv/fs_event.rb
libuv-2.0.0 lib/libuv/fs_event.rb
libuv-1.3.0 lib/libuv/fs_event.rb