Files
zig-squashfs/src/util/offset_file.zig
T
Caleb Gardner 5975bbb4a2 Build is working again (on Zig master branch)
Re-added specifying thread count doing something
Added single-threaded performance to benchmark.sh
Added single-threaded test (currently getting stuck forever)
Various minor fixes revealed now that build is working again.
2026-05-24 06:47:50 -05:00

28 lines
717 B
Zig

//! A File where it's meaningful (to us) content starts at a given offset.
const std = @import("std");
const Io = std.Io;
const File = Io.File;
const Reader = Io.Reader;
const OffsetFile = @This();
map: Io.File.MemoryMap,
pub fn init(io: Io, fil: File, archive_size: u64, init_offset: u64) !OffsetFile {
return .{
.map = try fil.createMemoryMap(io, .{
.protection = .{ .read = true, .write = false, .execute = false },
.len = archive_size,
.offset = init_offset,
}),
};
}
pub fn deinit(self: *OffsetFile, io: Io) void {
self.map.destroy(io);
}
pub fn readerAt(self: OffsetFile, offset: u64) Reader {
return .fixed(self.map.memory[offset..]);
}