ona/src/oar.zig

47 lines
1.2 KiB
Zig
Raw Normal View History

const std = @import("std");
const sys = @import("./sys.zig");
///
/// An entry block of an Oar archive file.
///
/// Typically, following this block in memory is the file data it holds the meta-information for.
///
pub const Entry = extern struct {
2022-10-11 01:15:19 +01:00
signature: [3]u8 = signature_magic,
2022-10-11 01:03:02 +01:00
revision: u8,
name_buffer: [255]u8 = std.mem.zeroes([255]u8),
name_length: u8 = 0,
file_size: u64,
file_offset: u64,
padding: [232]u8 = std.mem.zeroes([232]u8),
2022-10-11 01:03:02 +01:00
comptime {
const entry_size = @sizeOf(Entry);
if (entry_size != 512)
@compileError("Entry is " ++ std.fmt.comptimePrint("{d}", .{entry_size}) ++ " bytes");
2022-10-11 01:03:02 +01:00
}
///
2022-10-14 01:13:26 +01:00
/// [FindError.EntryNotFound] happens when an entry could not be found.
2022-10-11 01:03:02 +01:00
///
pub const FindError = sys.FileAccess.Error || error {
EntryNotFound,
};
2022-10-11 01:03:02 +01:00
///
///
///
pub fn find(file_access: sys.FileAccess, entry_name: []const u8) FindError!Entry {
_ = file_access;
_ = entry_name;
2022-10-11 01:03:02 +01:00
return error.EntryNotFound;
2022-10-11 01:03:02 +01:00
}
///
/// Magic identifier used to validate [Entry] data.
///
2022-10-11 01:15:19 +01:00
const signature_magic = [3]u8{'o', 'a', 'r'};
};