Blame docs/src/fs_event.rst

Packit Service 7c31a4
Packit Service 7c31a4
.. _fs_event:
Packit Service 7c31a4
Packit Service 7c31a4
:c:type:`uv_fs_event_t` --- FS Event handle
Packit Service 7c31a4
===========================================
Packit Service 7c31a4
Packit Service 7c31a4
FS Event handles allow the user to monitor a given path for changes, for example,
Packit Service 7c31a4
if the file was renamed or there was a generic change in it. This handle uses
Packit Service 7c31a4
the best backend for the job on each platform.
Packit Service 7c31a4
Packit Service 7c31a4
.. note::
Packit Service 7c31a4
    For AIX, the non default IBM bos.ahafs package has to be installed.
Packit Service 7c31a4
    The AIX Event Infrastructure file system (ahafs) has some limitations:
Packit Service 7c31a4
Packit Service 7c31a4
        - ahafs tracks monitoring per process and is not thread safe. A separate process
Packit Service 7c31a4
          must be spawned for each monitor for the same event.
Packit Service 7c31a4
        - Events for file modification (writing to a file) are not received if only the
Packit Service 7c31a4
          containing folder is watched.
Packit Service 7c31a4
Packit Service 7c31a4
    See documentation_ for more details.
Packit Service 7c31a4
Packit Service 7c31a4
    The z/OS file system events monitoring infrastructure does not notify of file
Packit Service 7c31a4
    creation/deletion within a directory that is being monitored.
Packit Service 7c31a4
    See the `IBM Knowledge centre`_ for more details.
Packit Service 7c31a4
Packit Service 7c31a4
    .. _documentation: https://developer.ibm.com/articles/au-aix_event_infrastructure/
Packit Service 7c31a4
    .. _`IBM Knowledge centre`: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.2.0/com.ibm.zos.v2r1.bpxb100/ioc.htm
Packit Service 7c31a4
Packit Service 7c31a4
Packit Service 7c31a4
Packit Service 7c31a4
Packit Service 7c31a4
Data types
Packit Service 7c31a4
----------
Packit Service 7c31a4
Packit Service 7c31a4
.. c:type:: uv_fs_event_t
Packit Service 7c31a4
Packit Service 7c31a4
    FS Event handle type.
Packit Service 7c31a4
Packit Service 7c31a4
.. c:type:: void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename, int events, int status)
Packit Service 7c31a4
Packit Service 7c31a4
    Callback passed to :c:func:`uv_fs_event_start` which will be called repeatedly
Packit Service 7c31a4
    after the handle is started. If the handle was started with a directory the
Packit Service 7c31a4
    `filename` parameter will be a relative path to a file contained in the directory.
Packit Service 7c31a4
    The `events` parameter is an ORed mask of :c:type:`uv_fs_event` elements.
Packit Service 7c31a4
Packit Service 7c31a4
.. c:type:: uv_fs_event
Packit Service 7c31a4
Packit Service 7c31a4
    Event types that :c:type:`uv_fs_event_t` handles monitor.
Packit Service 7c31a4
Packit Service 7c31a4
    ::
Packit Service 7c31a4
Packit Service 7c31a4
        enum uv_fs_event {
Packit Service 7c31a4
            UV_RENAME = 1,
Packit Service 7c31a4
            UV_CHANGE = 2
Packit Service 7c31a4
        };
Packit Service 7c31a4
Packit Service 7c31a4
.. c:type:: uv_fs_event_flags
Packit Service 7c31a4
Packit Service 7c31a4
    Flags that can be passed to :c:func:`uv_fs_event_start` to control its
Packit Service 7c31a4
    behavior.
Packit Service 7c31a4
Packit Service 7c31a4
    ::
Packit Service 7c31a4
Packit Service 7c31a4
        enum uv_fs_event_flags {
Packit Service 7c31a4
            /*
Packit Service 7c31a4
            * By default, if the fs event watcher is given a directory name, we will
Packit Service 7c31a4
            * watch for all events in that directory. This flags overrides this behavior
Packit Service 7c31a4
            * and makes fs_event report only changes to the directory entry itself. This
Packit Service 7c31a4
            * flag does not affect individual files watched.
Packit Service 7c31a4
            * This flag is currently not implemented yet on any backend.
Packit Service 7c31a4
            */
Packit Service 7c31a4
            UV_FS_EVENT_WATCH_ENTRY = 1,
Packit Service 7c31a4
            /*
Packit Service 7c31a4
            * By default uv_fs_event will try to use a kernel interface such as inotify
Packit Service 7c31a4
            * or kqueue to detect events. This may not work on remote file systems such
Packit Service 7c31a4
            * as NFS mounts. This flag makes fs_event fall back to calling stat() on a
Packit Service 7c31a4
            * regular interval.
Packit Service 7c31a4
            * This flag is currently not implemented yet on any backend.
Packit Service 7c31a4
            */
Packit Service 7c31a4
            UV_FS_EVENT_STAT = 2,
Packit Service 7c31a4
            /*
Packit Service 7c31a4
            * By default, event watcher, when watching directory, is not registering
Packit Service 7c31a4
            * (is ignoring) changes in its subdirectories.
Packit Service 7c31a4
            * This flag will override this behaviour on platforms that support it.
Packit Service 7c31a4
            */
Packit Service 7c31a4
            UV_FS_EVENT_RECURSIVE = 4
Packit Service 7c31a4
        };
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_event_init(uv_loop_t* loop, uv_fs_event_t* handle)
Packit Service 7c31a4
Packit Service 7c31a4
    Initialize the handle.
Packit Service 7c31a4
Packit Service 7c31a4
.. c:function:: int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, const char* path, unsigned int flags)
Packit Service 7c31a4
Packit Service 7c31a4
    Start the handle with the given callback, which will watch the specified
Packit Service 7c31a4
    `path` for changes. `flags` can be an ORed mask of :c:type:`uv_fs_event_flags`.
Packit Service 7c31a4
Packit Service 7c31a4
    .. note:: Currently the only supported flag is ``UV_FS_EVENT_RECURSIVE`` and
Packit Service 7c31a4
              only on OSX and Windows.
Packit Service 7c31a4
Packit Service 7c31a4
.. c:function:: int uv_fs_event_stop(uv_fs_event_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_event_getpath(uv_fs_event_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, including the null terminator.
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
.. seealso:: The :c:type:`uv_handle_t` API functions also apply.