Comments!
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
+20
-2
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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,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;
|
||||||
|
|||||||
Reference in New Issue
Block a user