libkyfilewatcher(3)

πŸ“¦ version 3.0.1.4, in arch rolling, ubuntu resolute, ubuntu stonking

πŸ’– 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 = 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
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 path
  • type β€” file monitoring type
  • attr β€” file monitoring attributes
  • maxdepth β€” specify the maximum depth for traversal search
  • recurType β€” 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 monitored
  • type β€” file monitoring type
  • attr β€” file monitoring attributes
  • maxdepth β€” specify the maximum depth for traversal search
  • recurType β€” 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 file
  • maxdepth β€” specify the maximum depth for traversal search
  • recurType β€” 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 πŸ”₯


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