Updated a lot of packed structs to extern struct

Specified int types for remaining packed structs
Instead of manually decoding File & ExtFile structs, decode an extern struct first
Fixed some zstd issues
Some more File stuff
This commit is contained in:
Caleb Gardner
2026-05-02 06:10:24 -05:00
parent ab606bdfa5
commit a3f7b86e67
11 changed files with 190 additions and 63 deletions
+20 -5
View File
@@ -3,6 +3,8 @@
const std = @import("std");
const Io = std.Io;
const Archive = @import("archive.zig");
const DirEntry = @import("directory.zig");
const ExtractionOptions = @import("options.zig");
const Inode = @import("inode.zig");
@@ -10,17 +12,21 @@ const File = @This();
alloc: std.mem.Allocator,
archive: Archive,
inode: Inode,
name: []const u8,
/// Creates a new File from an inode. Takes ownership of the Inode and creates a copy of the given name.
/// Requires the given allocator was used to create the Inode.
pub fn init(alloc: std.mem.Allocator, in: Inode, name: []const u8) !File {
pub fn init(alloc: std.mem.Allocator, archive: Archive, in: Inode, name: []const u8) !File {
const new_name = try alloc.alloc(u8, name.len);
@memcpy(new_name, name);
return .{
.alloc = alloc,
.archive = archive,
.inode = in,
.name = new_name,
};
@@ -31,10 +37,10 @@ pub fn deinit(self: File) void {
}
pub fn open(self: File, alloc: std.mem.Allocator, io: Io, filepath: []const u8) !File {
_ = self;
_ = alloc;
_ = io;
_ = filepath;
switch (self.inode.hdr.inode_type) {
.dir, .ext_dir => {},
else => return Error.NotDirectory,
}
return error.TODO;
}
@@ -46,3 +52,12 @@ pub fn extract(self: File, alloc: std.mem.Allocator, io: Io, filepath: []const u
_ = options;
return error.TODO;
}
// Types
pub const Error = error{
NotDirectory,
NotRegularFile,
NotSymlink,
NotDevice,
};