More refactoring in prep for a real design.

This commit is contained in:
Zed A. Shaw 2024-08-21 18:34:46 -04:00
parent b9e9119832
commit e35536c7e3
10 changed files with 229 additions and 186 deletions

31
watcher.cpp Normal file
View file

@ -0,0 +1,31 @@
#include "watcher.hpp"
#include <filesystem>
using namespace std;
namespace fs = std::filesystem;
void UpdateListener::handleFileAction(efsw::WatchID watchid,
const std::string& dir,
const std::string& filename,
efsw::Action action,
std::string oldFilename)
{
// this is some gnarly BS here, probably tons
// of memory leaks for now but it's working
int ignored = 1;
auto the_path = fs::path(dir) / fs::path(filename);
string full_path = the_path.lexically_normal().string();
std::replace(full_path.begin(),
full_path.end(), '\\', '/');
int rc = git_ignore_path_is_ignored(&ignored, repo, full_path.c_str());
if(!ignored) {
changes = changes || !ignored;
}
}
void UpdateListener::reset_state() {
changes = false;
}