Change types to idiomatic Ada_Case Odin
This commit is contained in:
@@ -24,13 +24,13 @@ Header :: struct #packed #all_or_none {
|
||||
number_of_assets: u32,
|
||||
}
|
||||
|
||||
AssetIndex :: struct #packed #all_or_none {
|
||||
Asset_Index :: struct #packed #all_or_none {
|
||||
relpath: [PATH_SIZE]u8,
|
||||
size: u64,
|
||||
offset: u64,
|
||||
}
|
||||
|
||||
AssetTable :: struct {
|
||||
Asset_Table :: struct {
|
||||
asset_index_offset: u64,
|
||||
data_offset: u64,
|
||||
asset_offsets: [dynamic]u64,
|
||||
@@ -40,7 +40,7 @@ AssetTable :: struct {
|
||||
Writer :: struct {
|
||||
chunk_file: ^os.File,
|
||||
asset_file: ^os.File,
|
||||
asset_table: AssetTable,
|
||||
asset_table: Asset_Table,
|
||||
}
|
||||
|
||||
Error :: union #shared_nil {
|
||||
@@ -61,7 +61,7 @@ writer_init :: proc(
|
||||
// [ Header ][ []Asset Index ][ Data ]
|
||||
w.asset_table.asset_index_offset = size_of(Header)
|
||||
w.asset_table.data_offset =
|
||||
size_of(Header) + (size_of(AssetIndex) * number_of_assets)
|
||||
size_of(Header) + (size_of(Asset_Index) * number_of_assets)
|
||||
w.asset_table.asset_offsets = make([dynamic]u64, allocator) or_return
|
||||
w.asset_table.asset_sizes = make([dynamic]u64, allocator) or_return
|
||||
resize(&w.asset_table.asset_offsets, number_of_assets)
|
||||
|
||||
@@ -12,7 +12,7 @@ import "src:file"
|
||||
write_assets :: proc(
|
||||
w: ^Writer,
|
||||
output: ^os.File,
|
||||
entries: []file.FileEntry,
|
||||
entries: []file.File_Entry,
|
||||
size_per_chunk: u64 = SIZE_PER_CHUNK,
|
||||
compression: u16 = COMPRESSION,
|
||||
allocator := context.allocator,
|
||||
|
||||
@@ -12,7 +12,7 @@ import "src:file"
|
||||
write_metadata :: proc(
|
||||
w: ^Writer,
|
||||
output: ^os.File,
|
||||
entries: []file.FileEntry,
|
||||
entries: []file.File_Entry,
|
||||
size_per_chunk: u64 = SIZE_PER_CHUNK,
|
||||
compression: u16 = COMPRESSION,
|
||||
allocator := context.allocator,
|
||||
@@ -71,11 +71,11 @@ write_header :: proc(
|
||||
write_asset_index :: proc(
|
||||
w: ^Writer,
|
||||
chunk_file: ^os.File,
|
||||
entries: []file.FileEntry,
|
||||
entries: []file.File_Entry,
|
||||
number_of_assets: u32,
|
||||
allocator: runtime.Allocator,
|
||||
) {
|
||||
index_size: u64 = size_of(AssetIndex) * cast(u64)number_of_assets
|
||||
index_size: u64 = size_of(Asset_Index) * cast(u64)number_of_assets
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
@@ -91,16 +91,16 @@ write_asset_index :: proc(
|
||||
os.exit(1)
|
||||
}
|
||||
|
||||
offset_in_bytes := size_of(AssetIndex) * cast(u64)i
|
||||
offset_in_bytes := size_of(Asset_Index) * cast(u64)i
|
||||
offset_pointer := mem.ptr_offset(&index_bytes[0], offset_in_bytes)
|
||||
|
||||
ai := cast(^AssetIndex)offset_pointer
|
||||
ai := cast(^Asset_Index)offset_pointer
|
||||
copy(ai.relpath[:PATH_SIZE], f.relpath)
|
||||
ai.size = w.asset_table.asset_sizes[i]
|
||||
ai.offset = w.asset_table.asset_offsets[i]
|
||||
}
|
||||
|
||||
assert(len(index_bytes) % size_of(AssetIndex) == 0) // clean multiple
|
||||
assert(len(index_bytes) % size_of(Asset_Index) == 0) // clean multiple
|
||||
|
||||
// Write asset index
|
||||
n, err := os.write_at(
|
||||
|
||||
@@ -7,7 +7,7 @@ import "core:strings"
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
FileEntry :: struct #all_or_none {
|
||||
File_Entry :: struct #all_or_none {
|
||||
relpath: string, // NOTE: owning string
|
||||
size: i64,
|
||||
}
|
||||
@@ -19,7 +19,7 @@ list_dir_recursive :: proc(
|
||||
f: ^os.File,
|
||||
working_dir: string,
|
||||
allocator := context.allocator,
|
||||
) -> [dynamic]FileEntry {
|
||||
) -> [dynamic]File_Entry {
|
||||
path := os.name(f)
|
||||
return list_dir_recursive_by_path_impl(path, working_dir, allocator)
|
||||
}
|
||||
@@ -29,12 +29,12 @@ list_dir_recursive_by_path :: proc(
|
||||
path: string,
|
||||
working_dir: string,
|
||||
allocator := context.allocator,
|
||||
) -> [dynamic]FileEntry {
|
||||
) -> [dynamic]File_Entry {
|
||||
return list_dir_recursive_by_path_impl(path, working_dir, allocator)
|
||||
}
|
||||
|
||||
// Frees every owning relpath string then the dynamic array itself.
|
||||
delete_entries :: proc(entries: ^[dynamic]FileEntry) {
|
||||
delete_entries :: proc(entries: ^[dynamic]File_Entry) {
|
||||
for entry in entries {
|
||||
delete(entry.relpath, entries.allocator)
|
||||
}
|
||||
@@ -46,13 +46,13 @@ list_dir_recursive_by_path_impl :: proc(
|
||||
path: string,
|
||||
working_dir: string,
|
||||
allocator: runtime.Allocator,
|
||||
) -> [dynamic]FileEntry {
|
||||
) -> [dynamic]File_Entry {
|
||||
if !os.is_dir(path) {
|
||||
fmt.eprintln("error: path is not a directory:", path)
|
||||
os.exit(1)
|
||||
}
|
||||
|
||||
result := make([dynamic]FileEntry, allocator)
|
||||
result := make([dynamic]File_Entry, allocator)
|
||||
|
||||
queue := make([dynamic]string, 0, 1, allocator) // reserve 1 slot
|
||||
defer delete(queue) // dynamic array embeds allocator
|
||||
@@ -68,7 +68,7 @@ list_dir_recursive_by_path_impl :: proc(
|
||||
@(private)
|
||||
list_dir_queue :: proc(
|
||||
queue: ^[dynamic]string,
|
||||
result: ^[dynamic]FileEntry,
|
||||
result: ^[dynamic]File_Entry,
|
||||
working_dir: string,
|
||||
allocator: runtime.Allocator,
|
||||
) {
|
||||
@@ -112,7 +112,7 @@ list_dir_queue :: proc(
|
||||
}
|
||||
append(
|
||||
result,
|
||||
FileEntry{relpath = relpath, size = entry.size},
|
||||
File_Entry{relpath = relpath, size = entry.size},
|
||||
)
|
||||
}
|
||||
case: // skip other types
|
||||
|
||||
Reference in New Issue
Block a user