Add even more tests and some impl improvements from their results

This commit is contained in:
Riyyi
2026-08-25 21:12:18 +02:00
parent 6e81c87501
commit ddaa3846f2
7 changed files with 292 additions and 58 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ Error :: union #shared_nil {
// -----------------------------------------
@(require_results)
format_error :: proc(ferr: Error) -> string {
error_string :: proc(ferr: Error) -> string {
if ferr == nil do return ""
switch e in ferr {
-2
View File
@@ -47,7 +47,6 @@ read_asset :: proc(
found, i := asset_exists(r, clean_path) or_return
if !found {
fmt.eprintln("asset: ", clean_path)
return nil, .Asset_Not_Exist
}
@@ -79,7 +78,6 @@ read_asset_from_chunk :: proc(
err: Error,
) {
if cast(u32)len(r.indices) < index {
fmt.eprintf("asset[{}]\n", index)
return nil, .Asset_Index_Out_Of_Bounds
}
+14 -3
View File
@@ -27,9 +27,21 @@ write_metadata :: proc(
chunk_file := os.open(chunk_path, {.Read, .Write}) or_return
defer os.close(chunk_file)
write_header(w, chunk_file, number_of_assets, size_per_chunk, compression)
write_header(
w,
chunk_file,
number_of_assets,
size_per_chunk,
compression,
) or_return
write_asset_index(w, chunk_file, entries, number_of_assets, allocator)
write_asset_index(
w,
chunk_file,
entries,
number_of_assets,
allocator,
) or_return
return nil
}
@@ -89,7 +101,6 @@ write_asset_index :: proc(
// TODO: Move to cli validation so it happens sooner
path_length := len(f.relpath)
if path_length > 512 {
fmt.eprintf("path: {} ({})\n", f.relpath, path_length)
return .Path_Too_Large
}
+1 -1
View File
@@ -40,7 +40,7 @@ get_working_dir :: proc(allocator := context.allocator) -> (string, Error) {
}
@(require_results)
format_error :: proc(ferr: Error) -> string {
error_string :: proc(ferr: Error) -> string {
if ferr == nil do return ""
switch e in ferr {
+3 -3
View File
@@ -31,7 +31,7 @@ main :: proc() {
entries, ld_err := file.list_dir_recursive(opts.input, working_dir)
if ld_err != nil {
fmt.eprintln("error:", file.format_error(ld_err))
fmt.eprintln("error:", file.error_string(ld_err))
os.exit(LIST_DIR_ERR)
}
defer file.delete_entries(&entries)
@@ -47,7 +47,7 @@ main :: proc() {
opts.compression,
)
if wa_err != nil {
fmt.eprintln("error:", chunks.format_error(wa_err))
fmt.eprintln("error:", chunks.error_string(wa_err))
os.exit(WRITE_ASSETS_ERR)
}
@@ -59,7 +59,7 @@ main :: proc() {
opts.compression,
)
if wm_err != nil {
fmt.eprintln("error:", chunks.format_error(wm_err))
fmt.eprintln("error:", chunks.error_string(wm_err))
os.exit(WRITE_METADATA_ERR)
}
}