DirWatcher
One-header lib for watching changes in folder using WinAPI in background thread
Install / Use
/learn @catinwarmhands/DirWatcherREADME
DirWatcher
DirWatcher is a header-only c++ library for watching changes in folder using WinAPI. Process will run in background thread.
Dependencies:
<thread>for threading<windows.h>for WinAPI calls<function>(optional, see below) for callback function
Copyright:
(c) 2017 by CIWH
License
Public domain
Usage:
- (Optional) You can define some actions before including:
DIRWATCHER_FAILED_WATCH_DIR_ACTIONwill be called if setting handle is failed,DIRWATCHER_FAILED_CLOSE_HANDLE_ACTIONwill be called if closing handle failed,DIRWATCHER_DEFAULT_CALLBACK_MESSAGEwill be inserted as code for default callback,DIRWATCHER_MESSAGE_BUFFER_SIZEis message buffer size (default is 1024 bytes)DIRWATCHER_USE_STD_FUNCTIONif defined - will usestd::functioninstead of function pointer for callback
#include "path/to/this/file/dirwatcher.hpp"- Create object:
ciwh::DirWatcher watcher;
- Defaults: dir is
., non-recursive (dont watch subfolders)
-
Set callback:
watcher.setCallback([](ciwh::FileActionType type, const char* filename){ /* your code here */ }) -
Run:
watcher.start(); -
(Optional, will be called in destructor) Stop:
watcher.stop();
You can chande dir via setDir(const char* path) method, set recursive mode via setRecursive(bool b) method.
If watcher was running, it will restart.
Getters are: bool isRecursive(), bool isRunning(), const char* const getDir()
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
