mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-05 21:38:40 +00:00
pre-allocate file size before write
This commit is contained in:
@@ -195,6 +195,10 @@ lnk_write_data_list_to_file_path(String8 path, String8 temp_path, String8List da
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!os_handle_match(file_handle, os_handle_zero())) {
|
if (!os_handle_match(file_handle, os_handle_zero())) {
|
||||||
|
if (!os_file_reserve_size(file_handle, data.total_size)) {
|
||||||
|
lnk_log(LNK_Log_IO_Write, "Failed to pre-allocate file %S with size %M", path, data.total_size);
|
||||||
|
}
|
||||||
|
|
||||||
// write data nodes
|
// write data nodes
|
||||||
{
|
{
|
||||||
for (String8Node *data_n = data.first; data_n != 0; data_n = data_n->next) {
|
for (String8Node *data_n = data.first; data_n != 0; data_n = data_n->next) {
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ internal FileProperties os_properties_from_file(OS_Handle file);
|
|||||||
internal OS_FileID os_id_from_file(OS_Handle file);
|
internal OS_FileID os_id_from_file(OS_Handle file);
|
||||||
internal B32 os_rename_file_by_handle(OS_Handle file, String8 new_name);
|
internal B32 os_rename_file_by_handle(OS_Handle file, String8 new_name);
|
||||||
internal B32 os_rename_file(String8 orig_name, String8 new_name);
|
internal B32 os_rename_file(String8 orig_name, String8 new_name);
|
||||||
|
internal B32 os_file_reserve_size(OS_Handle file, U64 size);
|
||||||
internal B32 os_delete_file_at_path(String8 path);
|
internal B32 os_delete_file_at_path(String8 path);
|
||||||
internal B32 os_copy_file_path(String8 dst, String8 src);
|
internal B32 os_copy_file_path(String8 dst, String8 src);
|
||||||
internal String8 os_full_path_from_path(Arena *arena, String8 path);
|
internal String8 os_full_path_from_path(Arena *arena, String8 path);
|
||||||
|
|||||||
@@ -494,6 +494,19 @@ os_rename_file_by_handle(OS_Handle file, String8 new_name)
|
|||||||
return is_renamed;
|
return is_renamed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal B32
|
||||||
|
os_file_reserve_size(OS_Handle file, U64 size)
|
||||||
|
{
|
||||||
|
HANDLE handle = (HANDLE)file.u64[0];
|
||||||
|
|
||||||
|
FILE_ALLOCATION_INFO alloc_info = {0};
|
||||||
|
alloc_info.AllocationSize.LowPart = size & max_U32;
|
||||||
|
alloc_info.AllocationSize.HighPart = (size >> 32) & max_U32;
|
||||||
|
|
||||||
|
BOOL is_reserved = SetFileInformationByHandle(handle, FileAllocationInfo, &alloc_info, sizeof(alloc_info));
|
||||||
|
return is_reserved;
|
||||||
|
}
|
||||||
|
|
||||||
internal B32
|
internal B32
|
||||||
os_delete_file_at_path(String8 path)
|
os_delete_file_at_path(String8 path)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user