Added uid & gid

This commit is contained in:
Caleb Gardner
2025-05-31 21:57:18 -05:00
parent d48ed4259e
commit fd1f83d855
2 changed files with 42 additions and 24 deletions
+9 -1
View File
@@ -59,7 +59,7 @@ pub const File = struct {
return out;
}
fn file_path(self: File, alloc: std.mem.Allocator) ![]u8 {
pub fn file_path(self: File, alloc: std.mem.Allocator) ![]u8 {
if (self.parent_path.len == 0) {
const out = try alloc.alloc(u8, self.name.len);
@memcpy(out, self.name);
@@ -68,6 +68,14 @@ pub const File = struct {
return std.mem.concat(alloc, u8, &[3][]const u8{ self.parent_path, "/", self.name });
}
pub fn uid(self: File, rdr: *Reader) !u32 {
return rdr.id_table.getValue(rdr, self.inode.header.uid_idx);
}
pub fn gid(self: File, rdr: *Reader) !u32 {
return rdr.id_table.getValue(rdr, self.inode.header.gid_idx);
}
pub fn deinit(self: *File, alloc: std.mem.Allocator) void {
self.inode.deinit();
alloc.free(self.name);