summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build_win32.bat4
-rw-r--r--src/search.cpp20
-rw-r--r--src/search.h1
-rw-r--r--src/unix/main_unix.cpp6
-rw-r--r--src/windows/main_windows.cpp1
5 files changed, 20 insertions, 12 deletions
diff --git a/build_win32.bat b/build_win32.bat
index 1916414..049426c 100644
--- a/build_win32.bat
+++ b/build_win32.bat
@@ -4,7 +4,7 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary
@set INCLUDES=/I..\.. /I..\..\backends
@set SOURCES=imgui/imgui*.cpp src/*.cpp imfiledialog/*.cpp src/windows/*.cpp imgui/backends/imgui_impl_win32.cpp src/widgets/*.cpp
@set LIBS=opengl32.lib Advapi32.lib Shell32.lib Ole32.lib User32.lib Pathcch.lib bin/debug/icon.res
-@set FLAGS=/DTS_DEBUG
+@set FLAGS=/DTS_DEBUG /DEBUG:FULL /Ob0 /MT /Oy- /Zi
windres misc/icon.rc -O coff -o bin/debug/icon.res
if "%1"=="-a" (
@@ -17,6 +17,6 @@ if "%1"=="-release" (
)
mkdir %OUT_DIR%
-cl /std:c++17 /nologo %FLAGS% /W3 /Zi /MD /EHsc /Isrc/windows /external:W0 /external:Iimgui /external:Iimgui/backends /Isrc /utf-8 %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fd%OUT_DIR%/vc140.pdb /Fo%OUT_DIR%/ /link %LIBS%
+cl /std:c++17 /nologo %FLAGS% /W3 /MD /EHsc /Isrc/windows /external:W0 /external:Iimgui /external:Iimgui/backends /Isrc /utf-8 %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fd%OUT_DIR%/vc140.pdb /Fo%OUT_DIR%/ /link %LIBS%
if "%1"=="-r" call "bin/debug/text-search.exe"
if "%1"=="-d" call devenv "bin/debug/text-search.exe"
diff --git a/src/search.cpp b/src/search.cpp
index 5f95e8e..a455630 100644
--- a/src/search.cpp
+++ b/src/search.cpp
@@ -334,19 +334,21 @@ static void *_ts_search_thread(void *args)
new_result->file_list_read_cursor++;
ts_mutex_unlock(&new_result->files.mutex);
- ts_found_file *f = *(ts_found_file **)ts_array_at(&new_result->files, read_cursor);
- ts_file_content content = ts_platform_read_file(f->path, "rb, ccs=UTF-8");
- if (content.file_error != FILE_ERROR_NONE) {
- f->error = content.file_error;
- }
- if (content.content_length > megabytes(new_result->max_file_size)) {
+
+ ts_found_file *f = *(ts_found_file **)ts_array_at(&new_result->files, read_cursor);
+ if (f->file_size > megabytes(new_result->max_file_size)) {
f->error = FILE_ERROR_TOO_BIG;
}
+ else {
+ ts_file_content content = ts_platform_read_file(f->path, "rb, ccs=UTF-8");
+ if (content.file_error != FILE_ERROR_NONE) {
+ f->error = content.file_error;
+ }
- if (f->error == FILE_ERROR_NONE) _ts_search_file(f, content, new_result);
-
- free(content.content);
+ if (f->error == FILE_ERROR_NONE) _ts_search_file(f, content, new_result);
+ free(content.content);
+ }
}
finish_early:
diff --git a/src/search.h b/src/search.h
index 27c7f04..e01aef2 100644
--- a/src/search.h
+++ b/src/search.h
@@ -7,6 +7,7 @@
typedef struct t_ts_found_file
{
utf8_int8_t *path;
+ size_t file_size;
uint32_t match_count;
uint16_t error;
bool collapsed;
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*));
diff --git a/src/windows/main_windows.cpp b/src/windows/main_windows.cpp
index 4b086e8..b7f29f7 100644
--- a/src/windows/main_windows.cpp
+++ b/src/windows/main_windows.cpp
@@ -425,6 +425,7 @@ void ts_platform_list_files_block(ts_search_result* result, wchar_t* start_dir)
f->match_count = 0;
f->error = 0;
f->collapsed = false;
+ f->file_size = (file_info.nFileSizeHigh * (MAXDWORD+1)) + file_info.nFileSizeLow;
WideCharToMultiByte(CP_UTF8,0,complete_file_path,-1,(LPSTR)f->path,MAX_INPUT_LENGTH, NULL, NULL);
ts_mutex_lock(&result->files.mutex);