Purpose
FS Poll handles allow the user to monitor a given path for changes. Unlike fs event, fs poll handles use stat to detect when a file has changed so they can work on file systems where fs event handles can’t.
new_fs_poll¶
uv.new_fs_poll()
Initialize the handle.
Parameters
none
Examples
local fs_poll_handle = uv.new_fs_poll()
fs_poll_start¶
uv.fs_poll_start( fs_poll_handle, callback, filepath, interval )
Check the file at path for changes every interval milliseconds.
Parameters
Name | Details |
---|---|
fs_poll_handle | The fs poll handle. |
callback | The callback function. |
filepath | The filepath to poll. |
interval | Amount in milliseconds. |
Tip
For maximum portability, use multi-second intervals. Sub-second intervals will not detect all changes on many file systems.
Examples
local function cb() print( 'polled' ) end uv.fs_poll_start( fs_poll_handle, cb, '/some/filepath', 2000 ) --every 2 secs
fs_poll_stop¶
uv.fs_poll_stop( fs_poll_handle )
Stop the handle, the callback will no longer be called.
Parameters
Name | Details |
---|---|
fs_poll_handle | The fs poll handle. |
Examples
uv.fs_poll_stop( fs_poll_handle )
fs_poll_getpath¶
uv.fs_poll_getpath( fs_poll_handle )
Get the path being monitored by the handle.
Parameters
Name | Details |
---|---|
fs_poll_handle | The fs poll handle. |
Examples
local polling_path = uv.fs_poll_getpath( fs_poll_handle )
See also¶
The following API functionality applies to all handles: