non-helper os_properties_from_file_path - can use accelerated path here which just looks at path for properties, rather than having to open a handle; also tweak txti layer to gracefully fail if a write happened between its load of file data

This commit is contained in:
Ryan Fleury
2024-01-19 10:00:53 -08:00
parent b5e604e6c8
commit c4242cf162
5 changed files with 177 additions and 152 deletions
+8
View File
@@ -1198,6 +1198,14 @@ os_file_path_exists(String8 path)
return 0;
}
internal FileProperties
os_properties_from_file_path(String8 path)
{
FileProperties props = {0};
NotImplemented;
return props;
}
//- rjf: file maps
internal OS_Handle
-9
View File
@@ -126,15 +126,6 @@ os_write_data_list_to_file_path(String8 path, String8List list)
return good;
}
internal FileProperties
os_properties_from_file_path(String8 path)
{
OS_Handle file = os_file_open(OS_AccessFlag_Read|OS_AccessFlag_ShareRead, path);
FileProperties props = os_properties_from_file(file);
os_file_close(file);
return props;
}
internal OS_FileID
os_id_from_file_path(String8 path)
{
+1 -1
View File
@@ -176,7 +176,6 @@ internal void os_relaunch_self(void);
internal String8 os_data_from_file_path(Arena *arena, String8 path);
internal B32 os_write_data_to_file_path(String8 path, String8 data);
internal B32 os_write_data_list_to_file_path(String8 path, String8List list);
internal FileProperties os_properties_from_file_path(String8 path);
internal OS_FileID os_id_from_file_path(String8 path);
internal S64 os_file_id_compare(OS_FileID a, OS_FileID b);
internal String8 os_string_from_file_range(Arena *arena, OS_Handle file, Rng1U64 range);
@@ -260,6 +259,7 @@ internal B32 os_delete_file_at_path(String8 path);
internal B32 os_copy_file_path(String8 dst, String8 src);
internal String8 os_full_path_from_path(Arena *arena, String8 path);
internal B32 os_file_path_exists(String8 path);
internal FileProperties os_properties_from_file_path(String8 path);
//- rjf: file maps
internal OS_Handle os_file_map_open(OS_AccessFlags flags, OS_Handle file);
+19
View File
@@ -791,6 +791,25 @@ os_file_path_exists(String8 path)
return exists;
}
internal FileProperties
os_properties_from_file_path(String8 path)
{
WIN32_FIND_DATAW find_data = {0};
Temp scratch = scratch_begin(0, 0);
String16 path16 = str16_from_8(scratch.arena, path);
HANDLE handle = FindFirstFileW((WCHAR *)path16.str, &find_data);
FindClose(handle);
FileProperties props = {0};
{
props.size = Compose64Bit(find_data.nFileSizeHigh, find_data.nFileSizeLow);
w32_dense_time_from_file_time(&props.created, &find_data.ftCreationTime);
w32_dense_time_from_file_time(&props.modified, &find_data.ftLastWriteTime);
props.flags = w32_file_property_flags_from_dwFileAttributes(find_data.dwFileAttributes);
}
scratch_end(scratch);
return props;
}
//- rjf: file maps
internal OS_Handle