ADDWATCHTARGETLISTRECURSIVE(3)

📦 version 3.0.1.4, in arch rolling, ubuntu resolute, ubuntu stonking

💖 ADDWATCHTARGETLISTRECURSIVE 💖

okay bestie, sit down, hydrate, grab a snack 🍓 — we're talking about addWatchTargetListRecursive, and it lives in the Library Functions Manual, section 3, so it's a library function, not something you yell at your shell. It ships with libkyfilewatcher and it's here to make your filesystem-watching dreams come true. No cap. 🦋


🌸 NAME 🌸

addWatchTargetListRecursive — 增加需要监听的文件列表

Which is just fancy talk for add the list of files that need to be watched. It does what it says, it says what it does, iconic behaviour honestly. ✨


🎀 SYNOPSIS 🎀

#include <libkyfilewatcher.hpp>

💫 Classes 💫

class KYSDK_FILEWATCHER::FileWatcher

💫 Functions 💫

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

And you link with -lkyfilewatcher. 🫶 That's the whole vibe.


✨ DETAILED DESCRIPTION ✨

The main function of this interface is to add a list of files that need to be monitored. That's the whole assignment, and it ate. 💅

  • urlList — a list of file paths. Like, a whole list. Give it the paths, it handles the rest. 🌈
  • type — the file watcher type, and it's an enumeration. Here's the full menu, no substitutions:
enum FileWatcherType{
    ONESHOT = 0,    //
仅报送一次事件。请注意事件发生后,监听符号会从监听列表中移除,下次再用需要重新add
    PERIODIC,
    NEVER
};

okay the ONESHOT comment is important so lemme translate: it only reports one event, and — listen closely bestie — once that event happens, the watch descriptor gets removed from the watch list, so if you want it again later you have to add it all over again. It's giving one-and-done. 💀

  • attr — the file watcher attribute, also an enum, also very demure, very mindful:
enum 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
};
  • maxdepth — the maximum depth specified for traversal search. Please set this. Do not go infinite, bestie, that's not the vibe. 🕳️
  • recurType — the recursive type, and yes, another enumeration:
enum RecursiveType{
    DIR = 1 << 0,
    REGULAR = 1 << 1,
    HIDDEN = 1 << 2,
    TMPFILE = 1 << 3,    //认为那些以~开头的是临时文件
    ALLFILE = HIDDEN | TMPFILE | DIR | REGULAR
};

And that TMPFILE comment? It means files starting with ~ are considered temporary files. Cute, correct, we love a naming convention. 🎀


😶 RETURN VALUE 😶

fr fr this section is literally empty in the original. Nothing here. Not me showing you an empty section, but that's how it is and I'm not about to invent facts. 🙈


🧚 EXAMPLES 🧚

Here's the example, exactly as written, go off:

#include <QCoreApplication>
#include <QDebug>
#include "libkyfilewatcher.hpp"

using namespace KYSDK_FILEWATCHER;

int main(int argc, char *argv[])
{
    KYSDK_FILEWATCHER::FileWatcher watcher;
    watcher.addWatchTargetRecursive("/home/kylin/", PERIODIC, ALL, 3, REGULAR);

    getchar();

//    qDebug() << "update attr test";
//    watcher.updateWatchTargetAttribute("/data/testcode/test.c", DELETE);

//    getchar();

//    qDebug() << "re-add test";
//    watcher.addWatchTarget("/data/testcode/test.c", PERIODIC, ALL);

//    getchar();

//    qDebug() << "update oneshot test";
//    watcher.updateWatchTargetType("/data/testcode/test.c", ONESHOT);

//    getchar();

//    qDebug() << "remove target test";
//    watcher.removeWatchTarget("/data/testcode/test.c");

//    getchar();

    watcher.clearWatchList();
    return 0;
}

Notice the commented-out blocks? That's your little tour of the other moves in the API — update the attribute, re-add, switch to ONESHOT, remove, all separated by getchar() so you can breathe between them. Main character energy. 👑


📜 CONFORMING TO 📜

These functions are as per the withdrawn POSIX.1e draft specification. And heads up, the following ones are Linux extensions: addWatchTargetRecursive(), removeWatchTargetRecursive(), clearWatchList(), pauseWatcher() and restartWatcher(). So if you're porting somewhere else, that's your vibe check right there. ⭐


👀 SEE ALSO 👀

addWatchTargetRecursive(3), removeWatchTargetRecursive(3), clearWatchList(3), pauseWatcher(3) and restartWatcher(3).

Go read those too, iykyk. 💜


okay that's the whole page, and as a lil sign-off: this came from My Project, dated Wed Sep 20 2023, and the page title is the slightly cropped addWatchTa...stRecursive(3). Slay, bye bestie! 🌸💖✨

📦 where this page comes from