Making things work properly

This commit is contained in:
Caleb Gardner
2025-05-17 09:05:24 -05:00
parent bbf3539dcf
commit f77c2ecf48
3 changed files with 37 additions and 34 deletions
+2 -21
View File
@@ -14,32 +14,12 @@ const FileError = error{
};
pub const File = struct {
reader: *Reader,
name: []const u8,
inode: inode.Inode,
pub fn fromRef(read: *Reader, ref: inode.InodeRef, name: []const u8) !File {
var meta_rdr: MetadataReader = try .init(
read.arena.allocator(),
read.holder.anyAt(ref.block_start + read.super.inode_table_start),
read.super.decomp,
);
defer meta_rdr.deinit();
try meta_rdr.skip(ref.offset);
return .{
.reader = read,
.name = name,
.inode = try .init(
read.arena.allocator(),
meta_rdr.any(),
read.super.block_size,
),
};
}
// pub fn fromDirEntry(read: Reader, ent: DirEntry) !File {}
pub fn open(self: File, path: []const u8) !File {
pub fn open(self: File, reader: *Reader, path: []const u8) !File {
if (path.len == 0 || std.mem.eql(u8, path, ".")) {
return self;
}
@@ -47,6 +27,7 @@ pub const File = struct {
.dir, .ext_dir => {},
else => return FileError.NotDirectory,
}
_ = reader;
//TODO: read dir entries and find correct inode and file
}