Class FsPollHandle

Synopsis

#include <src/uvw/fs_poll.h>

class FsPollHandle final: public Handle<FsPollHandle, uv_fs_poll_t>

Description

The FsPollHandle handle.

It allows the user to monitor a given path for changes. Unlike FsEventHandle handles, FsPollHandle handles use stat to detect when a file has changed so they can work on file systems where FsEventHandle handles can’t.

To create a FsPollHandle through a Loop, no arguments are required.

Inheritance

Ancestors: Handle

Methods

initInitializes the handle.
pathGets the path being monitored by the handle.
startStarts the handle.
stopStops the handle.

Source

Lines 38-73 in src/uvw/fs_poll.h.

class FsPollHandle final: public Handle<FsPollHandle, uv_fs_poll_t> {
    static void startCallback(uv_fs_poll_t *handle, int status, const uv_stat_t *prev, const uv_stat_t *curr);

public:
    using Time = std::chrono::duration<unsigned int, std::milli>;

    using Handle::Handle;

    /**
     * @brief Initializes the handle.
     * @return True in case of success, false otherwise.
     */
    bool init();

    /**
     * @brief Starts the handle.
     *
     * The handle will start emitting FsPollEvent when needed.
     *
     * @param file The path to the file to be checked.
     * @param interval Milliseconds between successive checks.
     */
    void start(const std::string &file, Time interval);

    /**
     * @brief Stops the handle.
     */
    void stop();

    /**
     * @brief Gets the path being monitored by the handle.
     * @return The path being monitored by the handle, an empty string in case
     * of errors.
     */
    std::string path() noexcept;
};





Add Discussion as Guest

Log in