Further progress

Mainly focusing on getting things more consistent
This commit is contained in:
Caleb Gardner
2025-07-12 02:13:41 -05:00
parent 61c86c9fea
commit 69d90242ba
9 changed files with 206 additions and 27 deletions
+55
View File
@@ -0,0 +1,55 @@
const std = @import("std");
const PRead = @import("p_read.zig").Pread;
const FragEntry = @import("../fragment.zig").FragEntry;
const BlockSize = @import("../inode/file.zig").BlockSize;
const Compression = @import("../superblock.zig").Compression;
pub fn DataReader(comptime T: type) type {
return struct {
const Self = @This();
alloc: std.mem.Allocator,
rdr: PRead(T),
comp: Compression,
offsets: []BlockSize,
file_size: u64,
block_size: u32,
sizes: []BlockSize,
frag: []u8 = undefined,
pub fn init(
alloc: std.mem.Allocator,
rdr: PRead(T),
comp: Compression,
init_offset: u64,
file_size: u64,
sizes: []BlockSize,
block_size: u32,
) !Self {
var cur_offset = init_offset;
const offsets = alloc.alloc(u64, sizes.len);
for (0..sizes.len) |i| {
offsets[i] = cur_offset;
cur_offset += sizes[i].size;
}
return .{
.alloc = alloc,
.rdr = rdr,
.comp = comp,
.offsets = offsets,
.file_size = file_size,
.block_size = block_size,
.sizes = sizes,
};
}
pub fn addFragment(self: *Self, entry: FragEntry, offset: u32) void {
self.frag = self.alloc.alloc(u8, self.file_size % self.block_size);
//TODO:
}
};
}