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);
+13 -3
View File
@@ -1,6 +1,7 @@
const std = @import("std");
const config = @import("config");
const File = @import("file.zig").File;
const Reader = @import("reader.zig").Reader;
const ExtractConfig = @import("file.zig").File.ExtractConfig;
@@ -131,7 +132,8 @@ pub fn main() !void {
try std.fmt.format(stdout.writer(), "Error opening {s} as squashfs: {any}\n", .{ filename, err });
return;
};
if (list == .None) {
switch (list) {
.None => {
var conf = ExtractConfig.init() catch |err| {
try std.fmt.format(stdout.writer(), "Error getting system info: {any}\n", .{err});
return;
@@ -157,7 +159,15 @@ pub fn main() !void {
};
}
}
return;
},
else => {},
}
//TODO: listing
}
fn printFile(rdr: *Reader, f: *File) !void {
if (f.name.len == 0) {
}
}
fn printDir(rdr: *Reader, f: *File) !void {}