Comments!

This commit is contained in:
Caleb J. Gardner
2026-01-31 05:14:00 -06:00
parent 1ff1e91d5e
commit a76803aad1
9 changed files with 37 additions and 4 deletions
+2
View File
@@ -1,3 +1,5 @@
//! Decompression manager. Can decompress either from an Io.Reader or from a byte slice.
const std = @import("std"); const std = @import("std");
const compress = std.compress; const compress = std.compress;
const Reader = std.Io.Reader; const Reader = std.Io.Reader;
+2
View File
@@ -1,3 +1,5 @@
//! Directory entry from the directory table.
const std = @import("std"); const std = @import("std");
const Reader = std.Io.Reader; const Reader = std.Io.Reader;
+21 -3
View File
@@ -1,3 +1,5 @@
//! A file/directory within the squashfs archive.
const std = @import("std"); const std = @import("std");
const File = std.fs.File; const File = std.fs.File;
const WaitGroup = std.Thread.WaitGroup; const WaitGroup = std.Thread.WaitGroup;
@@ -391,9 +393,25 @@ fn extractReal(self: SfsFile, path: []const u8, options: ExtractionOptions, pol:
}; };
}, },
.dir, .ext_dir => { .dir, .ext_dir => {
_ = std.fs.cwd().statFile(path) catch |err| { if (std.fs.cwd().statFile(path)) |stat| {
if (err == error.FileNotFound) {} if (stat.kind != .directory) {
}; std.log.err("{s} exists and is not a folder\n", .{path});
out_err.* = FileError.ExtractionPathExists;
return;
}
} else |err| {
if (err == error.FileNotFound) {
std.fs.cwd().makeDir(path) catch |err_2| {
std.log.err("Error creating {s}: {}\n", .{ path, err_2 });
out_err.* = err;
return;
};
} else {
std.log.err("Error checking if {s} exists: {}\n", .{ path, err });
out_err.* = err;
return;
}
}
var dir_wg: *WaitGroup = self.archive.allocator().create(WaitGroup) catch |err| { var dir_wg: *WaitGroup = self.archive.allocator().create(WaitGroup) catch |err| {
std.log.err("Error allocating waitgroup for {s} (inode {}): {}\n", .{ path, self.inode.hdr.num, err }); std.log.err("Error allocating waitgroup for {s} (inode {}): {}\n", .{ path, self.inode.hdr.num, err });
out_err.* = err; out_err.* = err;
+2
View File
@@ -1,3 +1,5 @@
//! A file-system object. Represents a File or directory.
const std = @import("std"); const std = @import("std");
const Reader = std.Io.Reader; const Reader = std.Io.Reader;
+4
View File
@@ -49,6 +49,7 @@ pub const ExtSymlink = struct {
} }
}; };
/// A block or character device.
pub const Dev = packed struct { pub const Dev = packed struct {
hard_links: u32, hard_links: u32,
dev: u32, dev: u32,
@@ -60,6 +61,7 @@ pub const Dev = packed struct {
} }
}; };
/// An extended block or character device.
pub const ExtDev = packed struct { pub const ExtDev = packed struct {
hard_links: u32, hard_links: u32,
dev: u32, dev: u32,
@@ -72,6 +74,7 @@ pub const ExtDev = packed struct {
} }
}; };
/// A socket or FIFO file.
pub const IPC = packed struct { pub const IPC = packed struct {
hard_links: u32, hard_links: u32,
@@ -82,6 +85,7 @@ pub const IPC = packed struct {
} }
}; };
/// An extended socket or FIFO file.
pub const ExtIPC = packed struct { pub const ExtIPC = packed struct {
hard_links: u32, hard_links: u32,
xattr_idx: u32, xattr_idx: u32,
+2
View File
@@ -1,3 +1,5 @@
//! Options for file/directory extraction.
const std = @import("std"); const std = @import("std");
const Writer = std.Io.Writer; const Writer = std.Io.Writer;
+1
View File
@@ -9,6 +9,7 @@ const TableError = error{
InvalidIndex, InvalidIndex,
}; };
/// A two-layer metadata table.
pub fn Table(T: anytype) type { pub fn Table(T: anytype) type {
return struct { return struct {
const Self = @This(); const Self = @This();
+2
View File
@@ -1,3 +1,5 @@
//! A reader for a regular file.
const std = @import("std"); const std = @import("std");
const Reader = std.Io.Reader; const Reader = std.Io.Reader;
const Writer = std.Io.Writer; const Writer = std.Io.Writer;
+1 -1
View File
@@ -1,4 +1,4 @@
//! A File that's meant where it's meaningful content starts at a given offset. //! A File where it's meaningful (to us) content starts at a given offset.
const std = @import("std"); const std = @import("std");
const File = std.fs.File; const File = std.fs.File;