mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-07 14:28:40 +00:00
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:
@@ -1198,6 +1198,14 @@ os_file_path_exists(String8 path)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal FileProperties
|
||||||
|
os_properties_from_file_path(String8 path)
|
||||||
|
{
|
||||||
|
FileProperties props = {0};
|
||||||
|
NotImplemented;
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
//- rjf: file maps
|
//- rjf: file maps
|
||||||
|
|
||||||
internal OS_Handle
|
internal OS_Handle
|
||||||
|
|||||||
@@ -126,15 +126,6 @@ os_write_data_list_to_file_path(String8 path, String8List list)
|
|||||||
return good;
|
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
|
internal OS_FileID
|
||||||
os_id_from_file_path(String8 path)
|
os_id_from_file_path(String8 path)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -176,7 +176,6 @@ internal void os_relaunch_self(void);
|
|||||||
internal String8 os_data_from_file_path(Arena *arena, String8 path);
|
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_to_file_path(String8 path, String8 data);
|
||||||
internal B32 os_write_data_list_to_file_path(String8 path, String8List list);
|
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 OS_FileID os_id_from_file_path(String8 path);
|
||||||
internal S64 os_file_id_compare(OS_FileID a, OS_FileID b);
|
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);
|
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 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);
|
||||||
internal B32 os_file_path_exists(String8 path);
|
internal B32 os_file_path_exists(String8 path);
|
||||||
|
internal FileProperties os_properties_from_file_path(String8 path);
|
||||||
|
|
||||||
//- rjf: file maps
|
//- rjf: file maps
|
||||||
internal OS_Handle os_file_map_open(OS_AccessFlags flags, OS_Handle file);
|
internal OS_Handle os_file_map_open(OS_AccessFlags flags, OS_Handle file);
|
||||||
|
|||||||
@@ -791,6 +791,25 @@ os_file_path_exists(String8 path)
|
|||||||
return exists;
|
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
|
//- rjf: file maps
|
||||||
|
|
||||||
internal OS_Handle
|
internal OS_Handle
|
||||||
|
|||||||
+11
-4
@@ -976,17 +976,20 @@ txti_mut_thread_entry_point(void *p)
|
|||||||
TXTI_Stripe *stripe = &txti_state->entity_map_stripes.v[stripe_idx];
|
TXTI_Stripe *stripe = &txti_state->entity_map_stripes.v[stripe_idx];
|
||||||
|
|
||||||
//- rjf: load file if we need it
|
//- rjf: load file if we need it
|
||||||
|
B32 load_valid = 0;
|
||||||
String8 file_contents = {0};
|
String8 file_contents = {0};
|
||||||
TXTI_LangKind lang_kind = TXTI_LangKind_Null;
|
TXTI_LangKind lang_kind = TXTI_LangKind_Null;
|
||||||
U64 timestamp = 0;
|
U64 timestamp = 0;
|
||||||
if(msg->kind == TXTI_MsgKind_Reload)
|
if(msg->kind == TXTI_MsgKind_Reload)
|
||||||
{
|
{
|
||||||
|
FileProperties pre_load_props = os_properties_from_file_path(msg->string);
|
||||||
OS_Handle file = os_file_open(OS_AccessFlag_Read|OS_AccessFlag_ShareRead|OS_AccessFlag_ShareWrite, msg->string);
|
OS_Handle file = os_file_open(OS_AccessFlag_Read|OS_AccessFlag_ShareRead|OS_AccessFlag_ShareWrite, msg->string);
|
||||||
FileProperties props = os_properties_from_file(file);
|
timestamp = pre_load_props.modified;
|
||||||
timestamp = props.modified;
|
file_contents = os_string_from_file_range(scratch.arena, file, r1u64(0, pre_load_props.size));
|
||||||
file_contents = os_string_from_file_range(scratch.arena, file, r1u64(0, props.size));
|
|
||||||
lang_kind = txti_lang_kind_from_extension(str8_skip_last_dot(msg->string));
|
lang_kind = txti_lang_kind_from_extension(str8_skip_last_dot(msg->string));
|
||||||
os_file_close(file);
|
os_file_close(file);
|
||||||
|
FileProperties post_load_props = os_properties_from_file_path(msg->string);
|
||||||
|
load_valid = (post_load_props.modified == pre_load_props.modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: nonzero lang kind -> unpack lang info
|
//- rjf: nonzero lang kind -> unpack lang info
|
||||||
@@ -1003,6 +1006,7 @@ txti_mut_thread_entry_point(void *p)
|
|||||||
|
|
||||||
//- rjf: detect line end kind
|
//- rjf: detect line end kind
|
||||||
TXTI_LineEndKind line_end_kind = TXTI_LineEndKind_Null;
|
TXTI_LineEndKind line_end_kind = TXTI_LineEndKind_Null;
|
||||||
|
if(load_valid)
|
||||||
{
|
{
|
||||||
U64 lf_count = 0;
|
U64 lf_count = 0;
|
||||||
U64 cr_count = 0;
|
U64 cr_count = 0;
|
||||||
@@ -1029,7 +1033,7 @@ txti_mut_thread_entry_point(void *p)
|
|||||||
|
|
||||||
//- rjf: obtain initial buffer_apply_gen, reset byte processing counters
|
//- rjf: obtain initial buffer_apply_gen, reset byte processing counters
|
||||||
U64 initial_buffer_apply_gen = 0;
|
U64 initial_buffer_apply_gen = 0;
|
||||||
OS_MutexScopeR(stripe->rw_mutex)
|
if(load_valid) OS_MutexScopeR(stripe->rw_mutex)
|
||||||
{
|
{
|
||||||
TXTI_Entity *entity = 0;
|
TXTI_Entity *entity = 0;
|
||||||
for(TXTI_Entity *e = slot->first; e != 0; e = e->next)
|
for(TXTI_Entity *e = slot->first; e != 0; e = e->next)
|
||||||
@@ -1052,6 +1056,8 @@ txti_mut_thread_entry_point(void *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: apply edits
|
//- rjf: apply edits
|
||||||
|
if(load_valid)
|
||||||
|
{
|
||||||
for(U64 buffer_apply_idx = 0;
|
for(U64 buffer_apply_idx = 0;
|
||||||
buffer_apply_idx < TXTI_ENTITY_BUFFER_COUNT;
|
buffer_apply_idx < TXTI_ENTITY_BUFFER_COUNT;
|
||||||
buffer_apply_idx += 1)
|
buffer_apply_idx += 1)
|
||||||
@@ -1220,6 +1226,7 @@ txti_mut_thread_entry_point(void *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//- rjf: end
|
//- rjf: end
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
|
|||||||
Reference in New Issue
Block a user