get directory name from OS instead of storing
This commit is contained in:
parent
8ea91269cd
commit
44756b2d5c
50
4ed.cpp
50
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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue