2020-12-16 14:53:48 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2021-06-29 13:06:12 +03:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
|
#define NOMINMAX
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
|
|
|
|
|
#include <thread>
|
|
|
|
|
#include <optional>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <functional>
|
2020-12-16 14:53:48 +01:00
|
|
|
|
2025-01-19 16:19:40 +01:00
|
|
|
#include <wil/resource.h>
|
|
|
|
|
#include <wil/filesystem.h>
|
|
|
|
|
|
2020-12-16 14:53:48 +01:00
|
|
|
class FileWatcher
|
|
|
|
|
{
|
|
|
|
|
std::wstring m_path;
|
2024-01-12 16:23:00 +01:00
|
|
|
std::wstring m_file_name;
|
2020-12-16 14:53:48 +01:00
|
|
|
std::optional<FILETIME> m_lastWrite;
|
|
|
|
|
std::function<void()> m_callback;
|
2024-01-12 16:23:00 +01:00
|
|
|
wil::unique_folder_change_reader_nothrow m_folder_change_reader;
|
|
|
|
|
|
2020-12-16 14:53:48 +01:00
|
|
|
std::optional<FILETIME> MyFileTime();
|
|
|
|
|
public:
|
2024-01-12 16:23:00 +01:00
|
|
|
FileWatcher(const std::wstring& path, std::function<void()> callback);
|
2020-12-16 14:53:48 +01:00
|
|
|
~FileWatcher();
|
|
|
|
|
};
|