https://github.com/fjebaker/znotify
An inotify wrapper for Zig.
https://github.com/fjebaker/znotify
Last synced: about 1 year ago
JSON representation
An inotify wrapper for Zig.
- Host: GitHub
- URL: https://github.com/fjebaker/znotify
- Owner: fjebaker
- License: gpl-3.0
- Created: 2024-05-10T05:20:53.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-24T22:32:43.000Z (over 1 year ago)
- Last Synced: 2025-04-05T01:06:59.524Z (about 1 year ago)
- Language: Zig
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# znotify
Extending Zig's standard library wrapper of `std.posix.inotify*` to be Ziggier.
```zig
const std = @import("std");
const znotify = @import("znotify");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
var notifier = try znotify.INotify.init(allocator);
defer notifier.deinit();
try notifier.watchPath(
"src",
.{
.create = true,
.modify = true,
.moved_to = true,
.moved_from = true,
.delete = true,
},
);
while (try notifier.poll()) |e| {
const path = try notifier.getPath(allocator, e);
defer allocator.free(path);
std.debug.print(
"NotifyEvent: {s} ({s}) dir: {any}\n",
.{ path, @tagName(e.event), e.dir },
);
}
}
```