addWatchTargetRecursive(3)
💖 addWatchTargetRecursive(3) — Library Functions Manual 💖
okay bestie, sit down, hydrate, because we're about to talk about addWatchTargetRecursive from the Library Functions Manual, and honestly? she's a baddie. ✨
🌸 NAME 🌸
addWatchTargetRecursive — 增加需要监听的文件路径,对于目录,默认启用递归监听子目录
(translation for my monolingual girlies: she adds the file paths you want watched, and if you hand her a directory, recursive watching of the subdirectories is switched on by default. no cap. 💅)
🎀 SYNOPSIS 🎀
#include <libkyfilewatcher.hpp>
✨ Classes ✨
class KYSDK_FILEWATCHER::FileWatcher
✨ Functions ✨
QStringList addWatchTargetRecursive(QString url, FileWatcherType type =
PERIODIC, int attr = OPEN|CLOSE|MODIFY|DELETE, int maxdepth = 5, int
recurType = DIR|REGULAR);
Link with -lkyfilewatcher. don't forget her, she will not come to you, you have to go to her 🫶
💅 Detailed Description 💅
The main character job of this interface is to add the file paths that need to be listened to, and for directories, recursive listening of subdirectories is enabled by default. periodt.
- The argument url is the file path.
- The argument type is the file watcher type,which is an enumeration type. The content is as follows:
enum FileWatcherType{
ONESHOT = 0, // 仅报送一次事件。请注意事件发生后,监听符号会从监听列表中移除,下次再用需要重新add
PERIODIC,
NEVER
};
🚨 okay soONESHOTmeans only one event gets reported, and heads up — after the event happens, the watch gets removed from the watch list, so next time you want it you gottaaddit again. it's giving one-time-use, she does not come back for round two 😭
- The argument attr is the file watcher attribute,which is an enumeration type. The content is as follows:
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
};
- The argument maxdepth is the maximum depth specified for traversal search. (how deep does she go? that's the vibe check ⭐)
- The argument recurType is the recursive type,which is an enumeration type. The content is as follows:
enum RecursiveType{
DIR = 1 << 0,
REGULAR = 1 << 1,
HIDDEN = 1 << 2,
TMPFILE = 1 << 3, //认为那些以~开头的是临时文件
ALLFILE = HIDDEN | TMPFILE | DIR | REGULAR
};
🍓 little translation moment: thatTMPFILEcomment means "consider the ones starting with~to be temporary files." iconic naming convention tbh
🌈 RETURN VALUE 🌈
(this section is literally empty in the original bestie, so… nothing to report, she's mysterious 💀)
👑 EXAMPLES 👑
#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;
}
like look at her go 🦋 watcher gets made, /home/kylin/ gets watched recursively with PERIODIC, ALL, depth 3, REGULAR, and then clearWatchList() cleans up at the end because we're responsible queens. the commented bits are just other tests vibing in the cut — leave them exactly as they are, they're part of the lore. 💜
🧚 CONFORMING TO 🧚
These functions are as per the withdrawn POSIX.1e draft specification.
The following functions are Linux extensions:
addWatchTargetListRecursive()removeWatchTargetRecursive()clearWatchList()pauseWatcher()restartWatcher()
⚠️ note the "withdrawn" part — POSIX.1e draft is retired, bestie, so don't go quoting her like she's current law. the Linux-extension girlies above are the ones doing the heavy lifting here. 💀
💖 SEE ALSO 💖
addWatchTargetListRecursive(3), removeWatchTargetRecursive(3), clearWatchList(3), pauseWatcher(3) and restartWatcher(3).
go read them too, the whole friend group ate 🔥
and that's the page, bestie!! 🫶 this manual came to you from My Project, dated Wed Sep 20 2023 — go off, you understood the whole thing, so proud of you, mwah 💅✨
📦 where this page comes from
- arch rolling: libkysdk-system 3.0.1.4-1 · LGPL-3.0-or-later AND LGPL-2.1-only OR LGPL-3.0-only AND LGPL-2.1-only WITH Qt-LGPL-exception-1.1 OR LGPL-3.0-only WITH Qt-LGPL-exception-1.1 AND MIT
- ubuntu resolute: libkysdk-system-dev 3.0.1.2-0ubuntu1 · LGPL-3.0-only
- ubuntu stonking: libkysdk-system-dev 3.0.1.3-0ubuntu1 · LGPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms