fixed 4.0.18 file track bug
parent
623026c655
commit
15aa7b6519
6
4ed.cpp
6
4ed.cpp
|
@ -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"
|
"If you're new to 4coder there are some tutorials at http://4coder.net/tutorials.html\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Newest features:\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"
|
"-New support for extended ascii input.\n"
|
||||||
"-Extended ascii encoded in buffers as utf8.\n"
|
"-Extended ascii encoded in buffers as utf8.\n"
|
||||||
"-The custom layer now has a 'markers' API for tracking buffer positions across changes.\n"
|
"-The custom layer now has a 'markers' API for tracking buffer positions across changes.\n"
|
||||||
|
|
|
@ -327,31 +327,45 @@ get_change_event(File_Track_System *system, Partition *scratch, u8 *buffer, i32
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_result){
|
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 len = info->FileNameLength / 2;
|
||||||
i32 dir_len = GetFinalPathNameByHandle_utf8(listener.dir, 0, 0, FILE_NAME_NORMALIZED);
|
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;
|
*size = req_size;
|
||||||
|
|
||||||
// TODO(allen): This check isn't really right, it should rely on the result from GetFinalPathNameByHandle_utf8.
|
// TODO(allen): This check isn't really right, it should rely on the result from GetFinalPathNameByHandle_utf8.
|
||||||
if (req_size < max){
|
if (req_size < max){
|
||||||
i32 pos = GetFinalPathNameByHandle_utf8(listener.dir, buffer, max, FILE_NAME_NORMALIZED);
|
u32 path_pos = GetFinalPathNameByHandle_utf8(listener.dir, buffer, max, FILE_NAME_NORMALIZED);
|
||||||
buffer[pos++] = '\\';
|
buffer[path_pos++] = '\\';
|
||||||
|
|
||||||
for (i32 i = 0; i < len; ++i, ++pos){
|
u32 name_max = max - path_pos;
|
||||||
buffer[pos] = (char)info->FileName[i];
|
u8 *name_buffer = buffer + path_pos;
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer[0] == '\\'){
|
b32 convert_error = false;
|
||||||
for (i32 i = 0; i+4 < pos; ++i){
|
u32 name_pos = (u32)utf16_to_utf8_minimal_checking(name_buffer, name_max, (u16*)info->FileName, len, &convert_error);
|
||||||
buffer[i] = buffer[i+4];
|
|
||||||
|
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{
|
else{
|
||||||
// TODO(allen): Need some way to stash this result so that if the
|
// TODO(allen): Need some way to stash this result so that if the
|
||||||
|
|
|
@ -43,6 +43,7 @@ GetFinalPathNameByHandle_utf8(HANDLE file, u8 *file_path_out, DWORD path_max, DW
|
||||||
|
|
||||||
if (file_path_out == 0){
|
if (file_path_out == 0){
|
||||||
result = GetFinalPathNameByHandleW(file, 0, 0, flags);
|
result = GetFinalPathNameByHandleW(file, 0, 0, flags);
|
||||||
|
result *= 2;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Partition *scratch = &shared_vars.scratch;
|
Partition *scratch = &shared_vars.scratch;
|
||||||
|
|
Loading…
Reference in New Issue