Added uid & gid
This commit is contained in:
+9
-1
@@ -59,7 +59,7 @@ pub const File = struct {
|
|||||||
return out;
|
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) {
|
if (self.parent_path.len == 0) {
|
||||||
const out = try alloc.alloc(u8, self.name.len);
|
const out = try alloc.alloc(u8, self.name.len);
|
||||||
@memcpy(out, self.name);
|
@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 });
|
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 {
|
pub fn deinit(self: *File, alloc: std.mem.Allocator) void {
|
||||||
self.inode.deinit();
|
self.inode.deinit();
|
||||||
alloc.free(self.name);
|
alloc.free(self.name);
|
||||||
|
|||||||
+33
-23
@@ -1,6 +1,7 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const config = @import("config");
|
const config = @import("config");
|
||||||
|
|
||||||
|
const File = @import("file.zig").File;
|
||||||
const Reader = @import("reader.zig").Reader;
|
const Reader = @import("reader.zig").Reader;
|
||||||
const ExtractConfig = @import("file.zig").File.ExtractConfig;
|
const ExtractConfig = @import("file.zig").File.ExtractConfig;
|
||||||
|
|
||||||
@@ -131,33 +132,42 @@ pub fn main() !void {
|
|||||||
try std.fmt.format(stdout.writer(), "Error opening {s} as squashfs: {any}\n", .{ filename, err });
|
try std.fmt.format(stdout.writer(), "Error opening {s} as squashfs: {any}\n", .{ filename, err });
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if (list == .None) {
|
switch (list) {
|
||||||
var conf = ExtractConfig.init() catch |err| {
|
.None => {
|
||||||
try std.fmt.format(stdout.writer(), "Error getting system info: {any}\n", .{err});
|
var conf = ExtractConfig.init() catch |err| {
|
||||||
return;
|
try std.fmt.format(stdout.writer(), "Error getting system info: {any}\n", .{err});
|
||||||
};
|
|
||||||
conf.deref_sym = deref;
|
|
||||||
conf.unbreak_sym = unbreak;
|
|
||||||
conf.verbose = verbose;
|
|
||||||
if (extr_files.items.len == 0) {
|
|
||||||
rdr.root.extract(&rdr, conf, extr_location) catch |err| {
|
|
||||||
try std.fmt.format(stdout.writer(), "Error extracting archive: {any}\n", .{err});
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
} else {
|
conf.deref_sym = deref;
|
||||||
for (extr_files.items) |path| {
|
conf.unbreak_sym = unbreak;
|
||||||
var fil = rdr.root.open(&rdr, path) catch |err| {
|
conf.verbose = verbose;
|
||||||
try std.fmt.format(stdout.writer(), "Error extracting {s}: {any}\n", .{ path, err });
|
if (extr_files.items.len == 0) {
|
||||||
return;
|
rdr.root.extract(&rdr, conf, extr_location) catch |err| {
|
||||||
};
|
try std.fmt.format(stdout.writer(), "Error extracting archive: {any}\n", .{err});
|
||||||
defer fil.deinit(alloc.allocator());
|
|
||||||
fil.extract(&rdr, conf, extr_location) catch |err| {
|
|
||||||
try std.fmt.format(stdout.writer(), "Error extracting {s}: {any}\n", .{ path, err });
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
for (extr_files.items) |path| {
|
||||||
|
var fil = rdr.root.open(&rdr, path) catch |err| {
|
||||||
|
try std.fmt.format(stdout.writer(), "Error extracting {s}: {any}\n", .{ path, err });
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
defer fil.deinit(alloc.allocator());
|
||||||
|
fil.extract(&rdr, conf, extr_location) catch |err| {
|
||||||
|
try std.fmt.format(stdout.writer(), "Error extracting {s}: {any}\n", .{ path, err });
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
return;
|
else => {},
|
||||||
}
|
}
|
||||||
//TODO: listing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn printFile(rdr: *Reader, f: *File) !void {
|
||||||
|
if (f.name.len == 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn printDir(rdr: *Reader, f: *File) !void {}
|
||||||
|
|||||||
Reference in New Issue
Block a user