diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-16 11:49:21 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-16 11:49:21 +0100 |
| commit | f8aa7d2a399ba7427e22c474191b1bd3331b647c (patch) | |
| tree | 464432a37e34f39c188aefef690466119288d86e /src/unix | |
| parent | fe4cf7b218974a05af58851878ba65d5f0e1f348 (diff) | |
retrieve file size during dir iteration instead of after opening file
Diffstat (limited to 'src/unix')
| -rw-r--r-- | src/unix/main_unix.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/unix/main_unix.cpp b/src/unix/main_unix.cpp index 755b617..0c58d02 100644 --- a/src/unix/main_unix.cpp +++ b/src/unix/main_unix.cpp @@ -303,10 +303,14 @@ void ts_platform_list_files_block(ts_search_result* result, wchar_t* start_dir) ts_found_file* f = (ts_found_file*)ts_memory_bucket_reserve(&result->memory, sizeof(ts_found_file)); f->path = (utf8_int8_t*)ts_memory_bucket_reserve(&result->memory, MAX_INPUT_LENGTH); + strcpy(f->path, complete_file_path); f->match_count = 0; f->error = 0; f->collapsed = false; - strcpy(f->path, complete_file_path); + + struct stat file_stat; + stat(f->path, &file_stat); + f->file_size = file_stat.st_size; ts_mutex_lock(&result->files.mutex); ts_array_push_size(&result->files, &f, sizeof(ts_found_file*)); |
