From 1e0cea02a5db185d11ff0db64299aa49dc69d40f Mon Sep 17 00:00:00 2001 From: anulax1225 Date: Mon, 25 Mar 2024 22:16:44 +0100 Subject: [PATCH] Reworked the file watcher --- src/bakatools/file_system/file_watcher.cpp | 8 ++++---- src/bakatools/file_system/file_watcher.h | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/bakatools/file_system/file_watcher.cpp b/src/bakatools/file_system/file_watcher.cpp index 2c083c3..b07caa0 100644 --- a/src/bakatools/file_system/file_watcher.cpp +++ b/src/bakatools/file_system/file_watcher.cpp @@ -10,7 +10,7 @@ namespace Bk::Tools { FileWatcher::~FileWatcher() { stop(); } - void FileWatcher::start(const std::function& action) + void FileWatcher::start(const std::function& action) { std::function task([&]() { @@ -19,7 +19,7 @@ namespace Bk::Tools { { if (!std::filesystem::exists(it->first)) { - action(it->first, FileStatus::Deleted); + action(it->first, FileStat::Deleted); it = paths.erase(it); } else it++; @@ -31,12 +31,12 @@ namespace Bk::Tools { { if(paths[file.path().string()] != current_file_last_write_time) { paths[file.path().string()] = current_file_last_write_time; - action(file.path().string(), FileStatus::Modified); + action(file.path().string(), FileStat::Modified); } } else { paths[file.path().string()] = current_file_last_write_time; - action(file.path().string(), FileStatus::Created); + action(file.path().string(), FileStat::Created); } } }); diff --git a/src/bakatools/file_system/file_watcher.h b/src/bakatools/file_system/file_watcher.h index 9c05b68..a9b446b 100644 --- a/src/bakatools/file_system/file_watcher.h +++ b/src/bakatools/file_system/file_watcher.h @@ -1,9 +1,10 @@ #pragma once -#include -#include +#include +#include + namespace Bk::Tools { - enum class FileStatus + enum class FileStat { Created = 0, Modified = 1, @@ -16,7 +17,7 @@ namespace Bk::Tools { FileWatcher(std::string path, TimeSpan ts); ~FileWatcher(); - void start(const std::function& action); + void start(const std::function& action); void stop(); bool contains(std::string path);