libkyfilewatcher(3)
π libkyfilewatcher β the file-watcher bestie page (manual section 3) π
okay so. hi. you found libkyfilewatcher(3), and honestly? slay. this is the little header-only-ish C++ library that watches your files for you so you don't have to sit there refreshing a directory like it's a group chat. it lives in libkyfilewatcher.hpp, it's part of the KYSDK family, and it is lowkey obsessed with inotify. let's get into it π¦
β¨ SYNOPSIS β¨
#include <libkyfilewatcher.hpp>
that's it. that's the whole entry point. include the header and you're in the building π
πΈ DESCRIPTION πΈ
this library hands you the file management interfaces and classes you need. that's the vibe: it watches, you chill.
π CLASSES π
KYSDK_FILEWATCHER::FileWatcher
the main character class, fr fr. it's your file management class, and here's the whole to-do list it's built for:
- 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
- resume file monitoring
that's it. that's the whole job. iconic behavior honestly.
π ENUMERATIONS π
FileWatcherType
ONESHOT = 0PERIODICNEVER
FileWatcherAttribute
ACCESS = IN_ACCESSCREATE = IN_CREATEMODIFY = IN_MODIFYDELETE = IN_DELETE | IN_DELETE_SELFATTRIB = IN_ATTRIBMOVE = IN_MOVE | IN_MOVE_SELFOPEN = IN_OPENCLOSE = IN_CLOSEALL = IN_ALL_EVENTS
RecursiveType
DIR = 1 << 0REGULAR = 1 << 1HIDDEN = 1 << 2TMPFILE = 1 << 3ALLFILE = HIDDEN | TMPFILE | DIR | REGULAR
not me being obsessed with ALLFILE just being all the other ones OR'd together. queen of efficiency π
π MEMBER FUNCTIONS π
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. and for directories? recursive monitoring of subdirectories is enabled by default, so it just goes down and down and down. she's thorough β¨
parameters, bestie:
urlβ file pathtypeβ file monitoring typeattrβ file monitoring attributesmaxdepthβ specify the maximum depth for traversal searchrecurTypeβ recursive type
return value:
QStringListβ 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 whole list of files that need to be monitored. batch mode. no cap.
parameters:
urlListβ list of files to be monitoredtypeβ file monitoring typeattrβ file monitoring attributesmaxdepthβ specify the maximum depth for traversal searchrecurTypeβ recursive type
return value:
QStringListβ 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. bye bye π (politely.)
parameters:
urlβ path of the specified filemaxdepthβ specify the maximum depth for traversal searchrecurTypeβ recursive type
return value:
QStringListβ list of successfully removed monitoring target paths
void clearWatchList ()
clear the monitoring list. one call, everything gone. it's giving "reset the timeline" π
void pauseWatcher ()
pause file monitoring. take a lil nap, girl.
void restartWatcher ()
resume file monitoring. okay we're back, we're refreshed, we're watching again π«Ά
π EXAMPLE USAGE π
#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;
}
see how maxdepth there is 3? and recurType isn't even passed so it defaults to DIR|REGULAR? yeah. defaults are doing the heavy lifting. we love a library that doesn't make you type everything πΈ
π§ AUTHOR π§
generated automatically by Doxygen for libkyfilewatcher.hpp from the source code. so like, a robot wrote this, but with love. (the robot's name is Doxygen. she's fine.)
π₯ SEE ALSO π₯
inotify(7)QFileSystemWatcher(3qt5)libkyfilewatcher(3)
and that's the page!! this was version 1.0, dated Wed Sep 20 2023, and it's your girl libkyfilewatcher(3) signing off. go watch some files, bestie. iykyk πβ¨π
π¦ 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