Cleanup CVT functions

This commit is contained in:
2025-07-20 15:13:13 +10:00
parent 804e5ed0a8
commit dbc3fe63f8
9 changed files with 202 additions and 190 deletions
+1 -1
View File
@@ -463,7 +463,7 @@ DN_API DN_Str8 DN_OS_ReadAll(DN_Arena *arena, DN_Str8 path, DN_OSErrSink *error)
result = DN_Str8_Alloc(arena, path_info.size, DN_ZeroMem_No);
if (!DN_Str8_HasData(result)) {
DN_OSTLSTMem tmem = DN_OS_TLSTMem(nullptr);
DN_Str8 buffer_size_str8 = DN_CVT_U64ToByteSizeStr8(tmem.arena, path_info.size, DN_CVTU64ByteSizeType_Auto);
DN_Str8 buffer_size_str8 = DN_CVT_U64ToBytesStr8AutoFromTLS(path_info.size);
DN_OS_ErrSinkAppendF(error, 1 /*error_code*/, "Failed to allocate %.*s for reading file '%.*s'", DN_STR_FMT(buffer_size_str8), DN_STR_FMT(path));
DN_Arena_TempMemEnd(temp_mem);
result = {};
+4 -4
View File
@@ -604,7 +604,7 @@ DN_API DN_OSFileRead DN_OS_FileRead(DN_OSFile *file, void *buffer, DN_USize size
DN_OSTLSTMem tmem = DN_OS_TLSTMem(nullptr);
if (!DN_Check(size <= (unsigned long)-1)) {
DN_Str8 buffer_size_str8 = DN_CVT_U64ToByteSizeStr8(tmem.arena, size, DN_CVTU64ByteSizeType_Auto);
DN_Str8 buffer_size_str8 = DN_CVT_U64ToBytesStr8AutoFromTLS(size);
DN_OS_ErrSinkAppendF(
err,
1 /*error_code*/,
@@ -658,9 +658,9 @@ DN_API bool DN_OS_FileWritePtr(DN_OSFile *file, void const *buffer, DN_USize siz
}
if (!result) {
DN_OSTLSTMem tmem = DN_OS_TLSTMem(nullptr);
DN_W32Error win_error = DN_W32_LastError(tmem.arena);
DN_Str8 buffer_size_str8 = DN_CVT_U64ToByteSizeStr8(tmem.arena, size, DN_CVTU64ByteSizeType_Auto);
DN_OSTLSTMem tmem = DN_OS_TLSTMem(nullptr);
DN_W32Error win_error = DN_W32_LastError(tmem.arena);
DN_Str8 buffer_size_str8 = DN_CVT_U64ToBytesStr8AutoFromTLS(size);
DN_OS_ErrSinkAppendF(err, win_error.code, "Failed to write buffer (%.*s) to file handle: %.*s", DN_STR_FMT(buffer_size_str8), DN_STR_FMT(win_error.msg));
}
return result;