libkyfilewatcher(3) File Watcher Library libkyfilewatcher(3)

libkyfilewatcher - File management functionality

#include <libkyfilewatcher.hpp>

This library provides file management interfaces and classes.

KYSDK_FILEWATCHER::FileWatcher

File management class. Mainly used to add file paths that need to be monitored, add file lists that need to be monitored, remove specified files from the monitoring list, clear the monitoring list, pause file monitoring, and resume file monitoring.

FileWatcherType

ONESHOT = 0
PERIODIC
NEVER

FileWatcherAttribute

ACCESS = IN_ACCESS
CREATE = IN_CREATE
MODIFY = IN_MODIFY
DELETE = IN_DELETE | IN_DELETE_SELF
ATTRIB = IN_ATTRIB
MOVE = IN_MOVE | IN_MOVE_SELF
OPEN = IN_OPEN
CLOSE = IN_CLOSE
ALL = IN_ALL_EVENTS

RecursiveType

DIR = 1 << 0
REGULAR = 1 << 1
HIDDEN = 1 << 2
TMPFILE = 1 << 3
ALLFILE = HIDDEN | TMPFILE | DIR | REGULAR

QStringList addWatchTargetRecursive (QString url, FileWatcherType type = PERIODIC, int attr = OPEN|CLOSE|MODIFY|DELETE, int maxdepth = 5, int recurType = DIR|REGULAR)

Add a file path that needs to be monitored. For directories, recursive monitoring of subdirectories is enabled by default.

Parameters:

File path
File monitoring type
File monitoring attributes
Specify the maximum depth for traversal search
Recursive type

Return value:

List of successfully added monitoring target paths

QStringList addWatchTargetListRecursive (QStringList urlList, FileWatcherType type = PERIODIC, int attr = OPEN|CLOSE|MODIFY|DELETE, int maxdepth = 5, int recurType = DIR|REGULAR)

Add a list of files that need to be monitored.

Parameters:

List of files to be monitored
File monitoring type
File monitoring attributes
Specify the maximum depth for traversal search
Recursive type

Return value:

List of successfully added monitoring target paths

QStringList removeWatchTargetRecursive (QString url, int maxdepth = 5, int recurType = ALLFILE)

Remove the specified file from the monitoring list.

Parameters:

Path of the specified file
Specify the maximum depth for traversal search
Recursive type

Return value:

List of successfully removed monitoring target paths

void clearWatchList ()

Clear the monitoring list.

void pauseWatcher ()

Pause file monitoring.

void restartWatcher ()

Resume file monitoring.

#include <libkyfilewatcher.hpp>
#include <QCoreApplication>
#include <QDebug>
using namespace KYSDK_FILEWATCHER;
int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);
    FileWatcher watcher;
    // Add directory monitoring
    QStringList paths = watcher.addWatchTargetRecursive(
        "/home/user/documents",
        PERIODIC,
        MODIFY | DELETE,
        3
    );
    // Pause and resume monitoring
    watcher.pauseWatcher();
    // ... perform some operations
    watcher.restartWatcher();
    return 0;
}

Generated automatically by Doxygen for libkyfilewatcher.hpp from the source code.

inotify(7), QFileSystemWatcher(3qt5), libkyfilewatcher(3)

Wed Sep 20 2023 1.0