zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit e9bd10cfda23252fb4188033a2edddd0c94d7fa3 (tree)
parent 56deb5b0545c049f7445003d12e50a052088b994
Author: xdBronch <51252236+xdBronch@users.noreply.github.com>
Date:   Sat,  2 Dec 2023 05:41:26 -0500

add getName helper to inotify_event

Diffstat:
Mlib/std/os/linux.zig | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig @@ -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 {