From 44756b2d5c15d6d7ba1bf6dacd184ad3ca28a916 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sat, 27 Aug 2016 10:42:47 -0400 Subject: [PATCH] get directory name from OS instead of storing --- 4ed.cpp | 50 ------------------------------ 4ed_file.cpp | 1 + 4ed_file_view.cpp | 2 +- filetrack/4tech_file_track.h | 2 +- filetrack/4tech_file_track_win32.c | 34 +++++++------------- 5 files changed, 14 insertions(+), 75 deletions(-) diff --git a/4ed.cpp b/4ed.cpp index 88234b8a..e8ee452a 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -1724,56 +1724,6 @@ App_Step_Sig(app_step){ end_temp_memory(temp); } -#if 0 - // NOTE(allen): check files are up to date - if (!input->first_step){ - Panel *panel = 0, *used_panels = &models->layout.used_sentinel; - for (dll_items(panel, used_panels)){ - View *view = panel->view; - Editing_File *file = view->file_data.file; - - terminate_with_null(&file->name.source_path); - u64 time_stamp = system->file_time_stamp(file->name.source_path.str); - - if (time_stamp > 0){ - if (file->state.last_sync < time_stamp){ - file_mark_behind_os(file); - } - } - } - - File_Node *node = models->working_set.sync_check_iter; - File_Node *used_nodes = &models->working_set.used_sentinel; - - if (node == used_nodes){ - node = node->next; - } - Assert(!((Editing_File*)node)->is_dummy); - - for (i32 i = 0; i < 4; ++i){ - if (node == used_nodes){ - break; - } - - Editing_File *file = (Editing_File*)node; - - terminate_with_null(&file->name.source_path); - u64 time_stamp = system->file_time_stamp(file->name.source_path.str); - - if (time_stamp > 0){ - if (file->state.last_sync < time_stamp){ - file_mark_behind_os(file); - } - } - } - - models->working_set.sync_check_iter = node; - } - else{ - models->working_set.sync_check_iter = &models->working_set.used_sentinel; - } -#endif - // NOTE(allen): reorganizing panels on screen { i32 prev_width = models->layout.full_width; diff --git a/4ed_file.cpp b/4ed_file.cpp index 6506de12..7753dec0 100644 --- a/4ed_file.cpp +++ b/4ed_file.cpp @@ -914,6 +914,7 @@ buffer_bind_file(System_Functions *system, General_Memory *general, Working_Set file->canon.name = make_fixed_width_string(file->canon.name_); copy(&file->canon.name, canon_filename); + terminate_with_null(&file->canon.name); system->add_listener(file->canon.name_); b32 result = working_set_canon_add(general, working_set, file, file->canon.name); Assert(result); AllowLocal(result); diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 7a95d22a..c0ec0196 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -4,7 +4,7 @@ * 19.08.2015 * * File editing view for 4coder -* +* */ // TOP diff --git a/filetrack/4tech_file_track.h b/filetrack/4tech_file_track.h index df24bfdf..c593f619 100644 --- a/filetrack/4tech_file_track.h +++ b/filetrack/4tech_file_track.h @@ -31,7 +31,7 @@ typedef struct{ uint8_t opaque[128]; } File_Track_System; -typedef int32_t File_Track_Result; +typedef int32_t File_Track_Result; File_Track_Result init_track_system(File_Track_System *system, diff --git a/filetrack/4tech_file_track_win32.c b/filetrack/4tech_file_track_win32.c index 0b11b1b8..cf73ea69 100644 --- a/filetrack/4tech_file_track_win32.c +++ b/filetrack/4tech_file_track_win32.c @@ -59,14 +59,6 @@ typedef struct { HANDLE dir; int32_t user_count; - char dir_name[512]; - int32_t dir_name_len; - - // TODO(allen): I am only ever using one thread - // for reading results. So is it possible to - // have them all go through the same location - // instead of having a different 2K block - // for each directory node? char result[2048]; } Directory_Listener; @@ -446,8 +438,7 @@ add_listener(File_Track_System *system, char *filename){ // TODO(allen): make this real! char dir_name[1024]; - int32_t dir_name_len = - internal_get_parent_name(dir_name, sizeof(dir_name), filename); + internal_get_parent_name(dir_name, sizeof(dir_name), filename); HANDLE dir = CreateFile( dir_name, @@ -484,14 +475,6 @@ add_listener(File_Track_System *system, char *filename){ node->listener.dir = dir; node->listener.user_count = 1; - // TODO(allen): make this real! - Assert(dir_name_len < sizeof(node->listener.dir_name)); - for (int32_t i = 0; i < dir_name_len; ++i){ - node->listener.dir_name[i] = dir_name[i]; - } - node->listener.dir_name[dir_name_len] = 0; - node->listener.dir_name_len = dir_name_len; - dir_lookup.entry->hash = dir_hash; dir_lookup.entry->dir = dir; dir_lookup.entry->listener_node = node; @@ -722,21 +705,26 @@ get_change_event(File_Track_System *system, char *buffer, int32_t max, int32_t * info = (FILE_NOTIFY_INFORMATION*)(listener_buffer + offset); int32_t len = info->FileNameLength / 2; - int32_t req_size = listener.dir_name_len + 1 + len; + int32_t dir_len =GetFinalPathNameByHandle(listener.dir, 0, 0, FILE_NAME_NORMALIZED); + int32_t req_size = dir_len + 1 + len; *size = req_size; if (req_size < max){ int32_t pos = 0; - char *src = listener.dir_name; - for (int32_t i = 0; src[i]; ++i, ++pos){ - buffer[pos] = src[i]; - } + pos = GetFinalPathNameByHandle(listener.dir, buffer, max, FILE_NAME_NORMALIZED); buffer[pos++] = '/'; for (int32_t i = 0; i < len; ++i, ++pos){ buffer[pos] = (char)info->FileName[i]; } + if (buffer[0] == '\\'){ + for (int32_t i = 0; i+4 < pos; ++i){ + buffer[i] = buffer[i+4]; + } + *size -= 4; + } + result = FileTrack_Good; } else{