|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
.. _fs_poll:
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
:c:type:`uv_fs_poll_t` --- FS Poll handle
|
|
Packit Service |
7c31a4 |
=========================================
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
FS Poll handles allow the user to monitor a given path for changes. Unlike
|
|
Packit Service |
7c31a4 |
:c:type:`uv_fs_event_t`, fs poll handles use `stat` to detect when a file has
|
|
Packit Service |
7c31a4 |
changed so they can work on file systems where fs event handles can't.
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
Data types
|
|
Packit Service |
7c31a4 |
----------
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
.. c:type:: uv_fs_poll_t
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
FS Poll handle type.
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
.. c:type:: void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, int status, const uv_stat_t* prev, const uv_stat_t* curr)
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
Callback passed to :c:func:`uv_fs_poll_start` which will be called repeatedly
|
|
Packit Service |
7c31a4 |
after the handle is started, when any change happens to the monitored path.
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
The callback is invoked with `status < 0` if `path` does not exist
|
|
Packit Service |
7c31a4 |
or is inaccessible. The watcher is *not* stopped but your callback is
|
|
Packit Service |
7c31a4 |
not called again until something changes (e.g. when the file is created
|
|
Packit Service |
7c31a4 |
or the error reason changes).
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
When `status == 0`, the callback receives pointers to the old and new
|
|
Packit Service |
7c31a4 |
:c:type:`uv_stat_t` structs. They are valid for the duration of the
|
|
Packit Service |
7c31a4 |
callback only.
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
Public members
|
|
Packit Service |
7c31a4 |
^^^^^^^^^^^^^^
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
N/A
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
.. seealso:: The :c:type:`uv_handle_t` members also apply.
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
API
|
|
Packit Service |
7c31a4 |
---
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
.. c:function:: int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle)
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
Initialize the handle.
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
.. c:function:: int uv_fs_poll_start(uv_fs_poll_t* handle, uv_fs_poll_cb poll_cb, const char* path, unsigned int interval)
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
Check the file at `path` for changes every `interval` milliseconds.
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
.. note::
|
|
Packit Service |
7c31a4 |
For maximum portability, use multi-second intervals. Sub-second intervals will not detect
|
|
Packit Service |
7c31a4 |
all changes on many file systems.
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
.. c:function:: int uv_fs_poll_stop(uv_fs_poll_t* handle)
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
Stop the handle, the callback will no longer be called.
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
.. c:function:: int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size)
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
Get the path being monitored by the handle. The buffer must be preallocated
|
|
Packit Service |
7c31a4 |
by the user. Returns 0 on success or an error code < 0 in case of failure.
|
|
Packit Service |
7c31a4 |
On success, `buffer` will contain the path and `size` its length. If the buffer
|
|
Packit Service |
7c31a4 |
is not big enough `UV_ENOBUFS` will be returned and `size` will be set to
|
|
Packit Service |
7c31a4 |
the required size.
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
.. versionchanged:: 1.3.0 the returned length no longer includes the terminating null byte,
|
|
Packit Service |
7c31a4 |
and the buffer is not null terminated.
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
.. versionchanged:: 1.9.0 the returned length includes the terminating null
|
|
Packit Service |
7c31a4 |
byte on `UV_ENOBUFS`, and the buffer is null terminated
|
|
Packit Service |
7c31a4 |
on success.
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
|
|
Packit Service |
7c31a4 |
.. seealso:: The :c:type:`uv_handle_t` API functions also apply.
|