We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4bfe5af commit 76029e0Copy full SHA for 76029e0
1 file changed
src/file_watcher.zig
@@ -0,0 +1,28 @@
1
+const STD = @import("std");
2
+
3
+const WATCH_POLLING_RATE_MS: u64 = 500;
4
5
+pub const FileWatcher = struct {
6
+ const Self = @This();
7
8
+ current_file_path: []const u8 = "",
9
+ previous_mod_time: i128 = 0,
10
11
+ pub fn init(file_path: []const u8) Self {
12
+ return Self{
13
+ .current_file_path = file_path,
14
+ };
15
+ }
16
17
+ pub fn checkForChanges(self: *Self) !bool {
18
+ const metadata = try STD.fs.cwd().statFile(self.current_file_path);
19
+ const current_mod_time = metadata.mtime;
20
21
+ if (current_mod_time != self.previous_mod_time) {
22
+ self.previous_mod_time = current_mod_time;
23
+ return true;
24
25
26
+ return false;
27
28
+};
0 commit comments