Skip to content

Corgile/filewatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

file watcher

#include <bitset>
#include <filesystem>
#include <iostream>
#include <memory>
#include "fw/Filter.h"
#include <fw/InotifyService.h>
using namespace std::chrono_literals;

int main(int argc, char* argv[]) {
  const auto path = fs::path(argv[1]);
  std::cout << "监听: '" << path.string() << "'" << std::endl;
  CallBackSignatur _call_back = [](const std::vector<Event::uptr>& events) {
    for (const auto& event : events) {
      std::cout << std::bitset<16>(event->type)
        << "; " << translate(event->type)
        << ": " << event->relativePath.string() << "\n";
    }
  };
  const auto _filter = std::make_shared<Filter>(_call_back);
  auto listenerInstance = InotifyService(_filter, path, 1ms);
  std::cout << "任意键退出" << std::endl;
  std::cin.ignore();

  return 0;
}

image

About

Linux directory / file changes notifier

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published