summaryrefslogtreecommitdiff
path: root/src/util/file_watcher.h
blob: 2766a43b3d874e6e4668e25795dda4219c0ae773 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// file_watcher.h - Hot-reload file change detection (debug only)

#ifndef FILE_WATCHER_H_
#define FILE_WATCHER_H_

#if !defined(STRIP_ALL)

#include <string>
#include <vector>
#include <ctime>

class FileWatcher {
 public:
  FileWatcher() = default;

  void add_file(const char* path);
  bool check_changes();
  void reset();

 private:
  struct WatchEntry {
    std::string path;
    time_t last_mtime;
    bool changed;
  };

  std::vector<WatchEntry> files_;
  time_t get_mtime(const char* path);
};

#endif  // !defined(STRIP_ALL)

#endif  // FILE_WATCHER_H_