fixed 4.0.18 file track bug

This commit is contained in:
Allen Webster 2017-03-30 16:48:33 -04:00
parent 623026c655
commit 15aa7b6519
3 changed files with 33 additions and 12 deletions

View File

@ -2302,6 +2302,12 @@ App_Step_Sig(app_step){
"If you're new to 4coder there are some tutorials at http://4coder.net/tutorials.html\n"
"\n"
"Newest features:\n"
"-Support for rendering unicode characters\n"
"-<ctrl t> isearch alpha-numeric word under cursor\n"
"-<ctrl Q> query replace alpha-numeric word under cursor\n"
"-<alt b> toggle file bar\n"
"\n"
"New in alpha 4.0.17:\n"
"-New support for extended ascii input.\n"
"-Extended ascii encoded in buffers as utf8.\n"
"-The custom layer now has a 'markers' API for tracking buffer positions across changes.\n"

View File

@ -327,31 +327,45 @@ get_change_event(File_Track_System *system, Partition *scratch, u8 *buffer, i32
}
if (has_result){
FILE_NOTIFY_INFORMATION *info = (FILE_NOTIFY_INFORMATION*)(listener.result + offset);
FILE_NOTIFY_INFORMATION *info = (FILE_NOTIFY_INFORMATION*)(((u8*)listener.result) + offset);
i32 len = info->FileNameLength / 2;
i32 dir_len = GetFinalPathNameByHandle_utf8(listener.dir, 0, 0, FILE_NAME_NORMALIZED);
i32 req_size = dir_len + 1 + len;
i32 req_size = dir_len + (len + 1)*2;
*size = req_size;
// TODO(allen): This check isn't really right, it should rely on the result from GetFinalPathNameByHandle_utf8.
if (req_size < max){
i32 pos = GetFinalPathNameByHandle_utf8(listener.dir, buffer, max, FILE_NAME_NORMALIZED);
buffer[pos++] = '\\';
u32 path_pos = GetFinalPathNameByHandle_utf8(listener.dir, buffer, max, FILE_NAME_NORMALIZED);
buffer[path_pos++] = '\\';
for (i32 i = 0; i < len; ++i, ++pos){
buffer[pos] = (char)info->FileName[i];
}
u32 name_max = max - path_pos;
u8 *name_buffer = buffer + path_pos;
if (buffer[0] == '\\'){
for (i32 i = 0; i+4 < pos; ++i){
buffer[i] = buffer[i+4];
b32 convert_error = false;
u32 name_pos = (u32)utf16_to_utf8_minimal_checking(name_buffer, name_max, (u16*)info->FileName, len, &convert_error);
if (name_pos < name_max){
if (!convert_error){
u32 pos = path_pos + name_pos;
*size = pos;
if (buffer[0] == '\\'){
for (u32 i = 0; i+4 < pos; ++i){
buffer[i] = buffer[i+4];
}
*size -= 4;
}
result = FileTrack_Good;
}
*size -= 4;
else{
result = FileTrack_FileSystemError;
}
}
else{
result = FileTrack_MemoryTooSmall;
}
result = FileTrack_Good;
}
else{
// TODO(allen): Need some way to stash this result so that if the

View File

@ -43,6 +43,7 @@ GetFinalPathNameByHandle_utf8(HANDLE file, u8 *file_path_out, DWORD path_max, DW
if (file_path_out == 0){
result = GetFinalPathNameByHandleW(file, 0, 0, flags);
result *= 2;
}
else{
Partition *scratch = &shared_vars.scratch;