add getName helper to inotify_event

This commit is contained in:
xdBronch
2023-12-02 05:41:26 -05:00
committed by Veikka Tuominen
parent 56deb5b054
commit e9bd10cfda

View File

@@ -3615,6 +3615,14 @@ pub const inotify_event = extern struct {
cookie: u32,
len: u32,
//name: [?]u8,
// if an event is returned for a directory or file inside the directory being watched
// returns the name of said directory/file
// returns `null` if the directory/file is the one being watched
pub fn getName(self: *const inotify_event) ?[:0]const u8 {
if (self.len == 0) return null;
return std.mem.sliceTo(@as([*:0]const u8, @ptrCast(self)) + @sizeOf(inotify_event), 0);
}
};
pub const dirent64 = extern struct {