Files
PowerToys/src/common/SettingsAPI/FileWatcher.h
Davide Giacometti 9e1242e8d5 [Common]NotificationUtil helper class with FileWatcher (#36720)
* add NotificationUtil helper with file watcher and cache

* fix spellcheck

* indentation
2025-01-19 15:19:40 +00:00

28 lines
587 B
C++

#pragma once
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <Windows.h>
#include <thread>
#include <optional>
#include <string>
#include <functional>
#include <wil/resource.h>
#include <wil/filesystem.h>
class FileWatcher
{
std::wstring m_path;
std::wstring m_file_name;
std::optional<FILETIME> m_lastWrite;
std::function<void()> m_callback;
wil::unique_folder_change_reader_nothrow m_folder_change_reader;
std::optional<FILETIME> MyFileTime();
public:
FileWatcher(const std::wstring& path, std::function<void()> callback);
~FileWatcher();
};