mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
[FancyZones] Implement File Watcher (#8603)
* Implement File Watcher in FancyZones * Simplify code, address PR comments * Add check to result of CreateEventW * Rebase fix Removed unneeded newline. If we keep it now, VS will just remove it some other time.
This commit is contained in:
19
src/modules/fancyzones/lib/FileWatcher.h
Normal file
19
src/modules/fancyzones/lib/FileWatcher.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
class FileWatcher
|
||||
{
|
||||
DWORD m_refreshPeriod;
|
||||
std::wstring m_path;
|
||||
std::optional<FILETIME> m_lastWrite;
|
||||
std::function<void()> m_callback;
|
||||
HANDLE m_abortEvent;
|
||||
std::thread m_thread;
|
||||
|
||||
std::optional<FILETIME> MyFileTime();
|
||||
void Run();
|
||||
public:
|
||||
FileWatcher(const std::wstring& path, std::function<void()> callback, DWORD refreshPeriod = 1000);
|
||||
~FileWatcher();
|
||||
};
|
||||
Reference in New Issue
Block a user