683,18 → 683,8 |
; read error |
cmp [copy_bSkipAll], 0 |
jnz .skip1 |
push execdata |
push aCannotReadFolder |
call get_error_msg |
push eax |
mov eax, esp |
push DeleteErrorBtn |
push 4 |
push eax |
push 3 |
call SayErr |
add esp, 3*4 |
test al, al |
mov edx, execdata |
call recursive_read_folder_err |
jz .read_retry |
cmp al, 2 |
jnz @f |
884,6 → 874,36 |
mov byte [esi+1], 0 |
ret |
|
recursive_read_folder_err: |
push edx |
push aCannotReadFolder |
call get_error_msg |
push eax |
mov eax, esp |
push DeleteErrorBtn |
push 4 |
push eax |
push 3 |
call SayErr |
add esp, 3*4 |
test al, al |
ret |
|
recursive_read_file_err: |
push edx |
push aCannotReadFile |
call get_error_msg |
push eax |
mov eax, esp |
push DeleteErrorBtn |
push 4 |
push eax |
push 3 |
call SayErr |
add esp, 3*4 |
test al, al |
ret |
|
copy_AddDir: |
push 1 |
pop eax ; for "return true" |
931,7 → 951,1016 |
setna al |
ret 12 |
|
search_dir_query_size = 32 |
search_filebuf_size = 32768 |
|
virtual at 0 |
filesearch_data: |
.prev_screen_vtable dd ? ; previous in window stack |
.prev_screen_data dd ? |
.tid dd ? ; -1 for query stage, secondary thread id for search stage |
.slot dd ? ; 0 if secondary thread is not running, it's slot otherwise |
.result_blocks dd ? ; head of heap blocks for resulting data |
.cur_result_ptr dd ? ; offset of free data in the current heap block for result |
.stop db ? ; set to 1 when secondary thread need to be stopped |
.skip_errors_mask db ? |
.skip_read_folder = 1 |
.skip_set_folder = 2 |
.skip_open_file = 4 |
.skip_read_file = 8 |
.skip_bigname = 10h |
.updating db ? |
.datachanged db ? |
.list.curitemptr dd ? |
.list.numitems dd ? |
.list.head dd ? |
.list.curitem dd ? |
.list.end dd ? |
.query_dlgdata rb filesearch_query_template.size |
.search_dlgdata rb filesearch_search_template.size |
.mask.maxlen dd ? |
.mask.pos dd ? |
.mask.start dd ? |
.mask rb 512 |
.string.maxlen dd ? |
.string.pos dd ? |
.string.start dd ? |
.string rb 256 |
.caption rb 268 |
.statusstr rb 80 |
.stack rb 8192 |
.stacktop = $ |
.fs.func dd ? |
.fs.pos_low dd ? |
.fs.pos_high dd ? |
.fs.size dd ? |
.fs.ptr dd ? |
.curfile rb 1024 |
.curdir rb 1024 |
.lowername rb 264 |
.dir_area rb 32 + 304*search_dir_query_size |
.filebuf rb search_filebuf_size |
.size = $ |
end virtual |
|
panels_OnKey.alt_f7: |
mov ecx, filesearch_data.size |
mov edx, filesearch_vtable |
call new_screen |
test eax, eax |
jnz @f |
ret |
@@: |
mov [ebp+filesearch_data.prev_screen_vtable], panels_vtable |
mov ecx, (filesearch_query_template.size + filesearch_search_template.size) / 4 |
mov esi, filesearch_query_template |
lea edi, [ebp+filesearch_data.query_dlgdata] |
rep movsd |
lea eax, [ebp+filesearch_data.string.maxlen] |
xor ebx, ebx |
mov dword [ebp+filesearch_data.query_dlgdata+filesearch_query_template.editptr2-filesearch_query_template], eax |
mov dword [eax], 253 |
mov [eax+4], ebx |
mov [eax+8], ebx |
mov [eax+12], bl |
sub eax, filesearch_data.string - filesearch_data.mask |
mov dword [ebp+filesearch_data.query_dlgdata+filesearch_query_template.editptr1-filesearch_query_template], eax |
mov dword [eax], 511 |
mov [eax+8], ebx |
inc ebx |
mov word [eax+12], '*' |
mov [eax+4], ebx |
mov eax, [find_in_file_dlgdata.flags_case] |
and al, 10h |
or al, 8 |
mov dword [ebp+filesearch_data.query_dlgdata+filesearch_query_template.flags_case-filesearch_query_template], eax |
mov eax, [find_in_file_dlgdata.flags_whole] |
and al, 10h |
or al, 8 |
mov dword [ebp+filesearch_data.query_dlgdata+filesearch_query_template.flags_whole-filesearch_query_template], eax |
lea edi, [ebp+filesearch_data.caption] |
mov dword [ebp+dlgtemplate.title+filesearch_data.search_dlgdata], edi |
lea eax, [ebp+filesearch_data.list.curitemptr] |
mov dword [ebp+filesearch_data.search_dlgdata+filesearch_search_template.data1-filesearch_search_template], eax |
.reinit: |
xor ebx, ebx |
or [ebp+filesearch_data.tid], -1 |
mov [ebp+filesearch_data.slot], ebx |
mov [ebp+filesearch_data.result_blocks], ebx |
mov [ebp+filesearch_data.cur_result_ptr], 0x4000 |
mov [ebp+filesearch_data.list.curitemptr], ebx |
mov [ebp+filesearch_data.list.numitems], ebx |
mov [ebp+filesearch_data.list.head], ebx |
mov [ebp+filesearch_data.list.curitem], ebx |
mov [ebp+filesearch_data.list.end], ebx |
mov [ebp+filesearch_data.stop], bl |
mov al, [dialog_main_color] |
mov [ebp+filesearch_data.query_dlgdata+dlgtemplate.main_color], al |
mov [ebp+filesearch_data.search_dlgdata+dlgtemplate.main_color], al |
mov al, [dialog_border_color] |
mov [ebp+filesearch_data.query_dlgdata+dlgtemplate.border_color], al |
mov [ebp+filesearch_data.search_dlgdata+dlgtemplate.border_color], al |
mov al, [dialog_header_color] |
mov [ebp+filesearch_data.query_dlgdata+dlgtemplate.header_color], al |
mov [ebp+filesearch_data.search_dlgdata+dlgtemplate.header_color], al |
filesearch_OnRedraw: |
push ebp |
mov byte [draw_image], 0xC3 |
mov eax, [ebp+filesearch_data.prev_screen_vtable] |
mov ebp, [ebp+filesearch_data.prev_screen_data] |
call dword [eax+screen_vtable.OnRedraw] |
mov byte [draw_image], 0xC6 |
pop ebp |
cmp [ebp+filesearch_data.tid], -1 |
jnz .prepare_search_dlg |
lea ebx, [ebp+filesearch_data.query_dlgdata] |
mov eax, [cur_width] |
mov [ebx + dlgtemplate.x], 6 |
sub eax, 12 |
mov [ebx + dlgtemplate.width], eax |
dec eax |
dec eax |
mov [ebx - filesearch_query_template + filesearch_query_template.width2], eax |
mov [ebx - filesearch_query_template + filesearch_query_template.width3], eax |
shr eax, 1 |
dec eax |
dec eax |
mov [ebx - filesearch_query_template + filesearch_query_template.search_x2], eax |
sub eax, aSearchBLength-1 |
mov [ebx - filesearch_query_template + filesearch_query_template.search_x1], eax |
add eax, aSearchBLength+3 |
mov [ebx - filesearch_query_template + filesearch_query_template.cnl_x1], eax |
add eax, aCancelBLength-1 |
mov [ebx - filesearch_query_template + filesearch_query_template.cnl_x2], eax |
mov eax, [cur_height] |
sub eax, [ebx + dlgtemplate.height] |
shr eax, 1 |
mov [ebx + dlgtemplate.y], eax |
jmp .dlg_prepared |
.prepare_search_dlg: |
lea ebx, [ebp+filesearch_data.search_dlgdata] |
; width: for big screens use all screen except for one column on each side, |
; that is, [cur_width] - 10 (standard frame width is 4); |
; if [cur_width]-10 does not contain enough place for all buttons with two spaces between them, |
; but [cur_width]-2 does, use fixed size = place for all buttons with two spaces between them |
; for small screens use [cur_width]-2 as maximum possible |
.btnsize = 2 + aNewSearchLen + 2 + aGotoLen + 2 + aViewLen + 2 + aCancelB2Length + 2 |
mov eax, [cur_width] |
mov edx, eax |
sub eax, 10 |
cmp eax, .btnsize |
jae @f |
add eax, 8 |
cmp eax, .btnsize |
jb @f |
mov al, .btnsize |
@@: |
mov [ebx + dlgtemplate.width], eax |
sub edx, eax |
shr edx, 1 |
mov [ebx + dlgtemplate.x], edx |
dec eax |
mov [ebx + filesearch_search_template.width1 - filesearch_search_template], eax |
mov [ebx + filesearch_search_template.width4 - filesearch_search_template], eax |
cmp [ebp + filesearch_data.slot], 0 |
jnz @f |
mov [ebx + filesearch_search_template.width3 - filesearch_search_template], eax |
@@: |
sub eax, aNewSearchLen + aGotoLen + aViewLen + aCancelB2Length - 1 |
cdq |
push 5 |
pop ecx |
idiv ecx |
sar edx, 1 |
add edx, eax |
inc eax |
mov [ebx + filesearch_search_template.btn1x1 - filesearch_search_template], edx |
add edx, aNewSearchLen-1 |
mov [ebx + filesearch_search_template.btn1x2 - filesearch_search_template], edx |
add edx, eax |
mov [ebx + filesearch_search_template.btn2x1 - filesearch_search_template], edx |
add edx, aGotoLen-1 |
mov [ebx + filesearch_search_template.btn2x2 - filesearch_search_template], edx |
add edx, eax |
mov [ebx + filesearch_search_template.btn3x1 - filesearch_search_template], edx |
add edx, aViewLen-1 |
mov [ebx + filesearch_search_template.btn3x2 - filesearch_search_template], edx |
add edx, eax |
mov [ebx + filesearch_search_template.btn4x1 - filesearch_search_template], edx |
add edx, aCancelB2Length-1 |
mov [ebx + filesearch_search_template.btn4x2 - filesearch_search_template], edx |
mov eax, [cur_height] |
mov edx, eax |
sub eax, 8 |
cmp eax, 6 |
jae @f |
mov eax, 6 |
@@: |
mov [ebx + dlgtemplate.height], eax |
sub edx, eax |
shr edx, 1 |
mov [ebx + dlgtemplate.y], edx |
dec eax |
mov [ebx + filesearch_search_template.btn1y - filesearch_search_template], eax |
mov [ebx + filesearch_search_template.btn2y - filesearch_search_template], eax |
mov [ebx + filesearch_search_template.btn3y - filesearch_search_template], eax |
mov [ebx + filesearch_search_template.btn4y - filesearch_search_template], eax |
dec eax |
mov [ebx + filesearch_search_template.y5 - filesearch_search_template], eax |
dec eax |
mov [ebx + filesearch_search_template.y3 - filesearch_search_template], eax |
mov [ebx + filesearch_search_template.y4 - filesearch_search_template], eax |
dec eax |
mov [ebx + filesearch_search_template.y2 - filesearch_search_template], eax |
dec eax |
mov [ebx + filesearch_search_template.height1 - filesearch_search_template], eax |
.dlg_prepared: |
call draw_dialog_shadow |
push ebx |
call DrawDialogBox |
ret |
|
filesearch_OnActivate: |
mov eax, [active_screen_data] |
cmp eax, ebp |
jz @f |
mov [ebp+filesearch_data.prev_screen_data], eax |
mov eax, [active_screen_vtable] |
mov [ebp+filesearch_data.prev_screen_vtable], eax |
@@: |
mov eax, [ebp+filesearch_data.prev_screen_data] |
mov ecx, [num_screens] |
mov edx, [screens] |
push edx |
@@: |
cmp [edx+4], eax |
jz @f |
add edx, 8 |
loop @b |
@@: |
pop edx |
jz @f |
mov eax, [active_screen] |
dec eax |
mov ecx, [edx+eax*8+4] |
mov [ebp+filesearch_data.prev_screen_data], ecx |
mov ecx, [edx+eax*8] |
mov [ebp+filesearch_data.prev_screen_vtable], ecx |
@@: |
cmp [ebp+filesearch_data.slot], 0 |
jz @f |
mov [idle_interval], 10 |
@@: |
; ret ; continue to filesearch_OnIdle |
|
filesearch_OnIdle: |
xor eax, eax |
xchg al, [ebp+filesearch_data.datachanged] |
cmp al, 1 |
ja .done |
jz .new |
.ret: |
ret |
.done: |
call filesearch_wait_thread |
call filesearch_done |
.new: |
jmp filesearch_OnRedraw |
|
filesearch_OnKey: |
cmp al, 0x58 |
jz F12 |
cmp [ebp+filesearch_data.tid], -1 |
jz .handle_generic |
cmp al, 0x47 |
jb .notforlist |
cmp al, 0x49 |
jbe @f |
cmp al, 0x4F |
jb .notforlist |
cmp al, 0x51 |
ja .notforlist |
@@: |
push ebp |
add ebp, filesearch_data.search_dlgdata |
lea ebx, [ebp+dlgtemplate.size+12] |
call listbox_key |
call draw_listbox |
call draw_image |
pop ebp |
ret |
.notforlist: |
cmp al, 0x3D |
jz .view |
.handle_generic: |
push ebp |
call filesearch_getcurdlg |
push 0 |
push eax |
push 2 |
push ebx |
call ManagerDlgProc |
pop ebp |
test eax, eax |
jz filesearch_OnIdle.ret |
cmp eax, -1 |
jz .esc |
sub eax, ebp |
cmp eax, filesearch_data.query_dlgdata+filesearch_query_template.search_btn-filesearch_query_template |
jz .query |
cmp eax, filesearch_data.search_dlgdata+filesearch_search_template.btn1-filesearch_search_template |
jz .newsearch |
cmp eax, filesearch_data.search_dlgdata+filesearch_search_template.btn2-filesearch_search_template |
jz .goto |
cmp eax, filesearch_data.search_dlgdata+filesearch_search_template.btn3-filesearch_search_template |
jz .view |
.esc: |
cmp dword [ebp+filesearch_data.slot], 0 |
jz .exit |
mov [ebp+filesearch_data.stop], 2 |
call ConfirmCancel |
setz [ebp+filesearch_data.stop] |
.ret: |
ret |
.exit: |
call filesearch_OnExit |
jmp delete_active_screen |
.view: |
mov esi, [ebp+filesearch_data.list.curitemptr] |
test esi, esi |
jz .ret |
add esi, 8 |
mov eax, esi |
jmp view_file |
.goto: |
mov esi, [ebp+filesearch_data.list.curitemptr] |
test esi, esi |
jz .ret |
add esi, 8 |
cmp byte [esi], '/' |
jnz .ret |
cmp byte [esi+1], 0 |
jz .ret |
push ebp |
mov ebp, [active_panel] |
push esi |
call close_plugin_panels |
pop esi |
mov ecx, esi |
@@: |
lodsb |
test al, al |
jnz @b |
@@: |
dec esi |
cmp byte [esi], '/' |
jnz @b |
mov byte [esi], 0 |
inc esi |
mov edi, saved_file_name |
@@: |
lodsb |
stosb |
test al, al |
jnz @b |
mov esi, ecx |
lea edi, [ebp + panel1_dir - panel1_data] |
push esi edi |
call strcmpi |
pop edi esi |
jz .goto.samedir |
@@: |
lodsb |
stosb |
test al, al |
jnz @b |
and [ebp + panel1_start - panel1_data], 0 |
and [ebp + panel1_index - panel1_data], 0 |
.goto.samedir: |
push @f |
push [ebp + panel1_index - panel1_data] |
jmp panels_OnKey.ctrl_r.doread |
@@: |
pop ebp |
jmp .exit |
.newsearch: |
cmp [ebp+filesearch_data.slot], 0 |
jz .do.newsearch |
call filesearch_stop_thread |
.do.newsearch: |
call filesearch_free_result |
jmp panels_OnKey.alt_f7.reinit |
.query: |
mov esi, [active_panel] |
cmp [esi + panel1_hPlugin - panel1_data], 0 |
jz @f |
push aCannotSearchOnPlugin |
mov eax, esp |
push ContinueBtn |
push 1 |
push eax |
push 1 |
call SayErr |
pop eax |
jmp .exit |
@@: |
add esi, panel1_dir - panel1_data |
lea edi, [ebp+filesearch_data.curdir] |
@@: |
lodsb |
stosb |
test al, al |
jnz @b |
push 51 |
pop eax |
push 1 |
pop ebx |
mov ecx, filesearch_thread |
lea edx, [ebp+filesearch_data.stacktop-4] |
mov [edx], ebp |
int 40h |
cmp eax, -1 |
jnz @f |
push ContinueBtn |
push 1 |
push aCannotCreateThread_ptr |
push 1 |
call SayErr |
ret |
@@: |
mov [ebp+filesearch_data.tid], eax |
mov [ebp+filesearch_data.updating], 0 |
mov [ebp+filesearch_data.datachanged], 0 |
xchg eax, ecx |
push 18 |
pop eax |
push 21 |
pop ebx |
int 40h |
mov [ebp+filesearch_data.slot], eax |
mov [idle_interval], 10 |
mov esi, aFileSearch |
mov edi, dword [ebp+filesearch_data.search_dlgdata+dlgtemplate.title] |
@@: |
lodsb |
stosb |
test al, al |
jnz @b |
mov byte [edi-1], ':' |
mov al, ' ' |
stosb |
lea esi, [ebp+filesearch_data.mask] |
@@: |
lodsb |
stosb |
test al, al |
jnz @b |
lea edi, [ebp+filesearch_data.statusstr] |
mov dword [ebp+filesearch_data.search_dlgdata+filesearch_search_template.data3-filesearch_search_template], edi |
mov esi, aSearchingIn |
@@: |
lodsb |
stosb |
cmp al, '"' |
jnz @b |
push esi |
push 10 |
pop ecx |
lea esi, [ebp+filesearch_data.string] |
@@: |
lodsb |
test al, al |
jz @f |
stosb |
loop @b |
@@: |
pop esi |
movsb |
jz @f |
mov byte [edi-1], '.' |
mov byte [edi-2], '.' |
mov byte [edi-3], '.' |
mov byte [edi-4], '"' |
@@: |
cmp byte [edi-2], '"' |
jnz @f |
sub edi, 3 |
@@: |
lodsb |
stosb |
test al, al |
jnz @b |
sub edi, dword [ebp+filesearch_data.search_dlgdata+filesearch_search_template.data3-filesearch_search_template] |
mov dword [ebp+filesearch_data.search_dlgdata+filesearch_search_template.width3-filesearch_search_template], edi |
inc edi |
mov dword [ebp+filesearch_data.search_dlgdata+filesearch_search_template.x4-filesearch_search_template], edi |
lea eax, [ebp+filesearch_data.curdir] |
mov dword [ebp+filesearch_data.search_dlgdata+filesearch_search_template.data4-filesearch_search_template], eax |
call filesearch_set_dlgflags ; use it? I think, yes |
cmp [ebp+filesearch_data.slot], 0 |
jnz @f |
call filesearch_done |
@@: |
jmp filesearch_OnRedraw |
|
filesearch_done: |
cmp [active_screen_data], ebp |
jnz @f |
or [idle_interval], -1 |
@@: |
and dword [ebp+filesearch_data.search_dlgdata+filesearch_search_template.data4-filesearch_search_template], 0 |
mov edi, dword [ebp+filesearch_data.search_dlgdata+filesearch_search_template.data3-filesearch_search_template] |
mov esi, aSearchDone |
@@: |
lodsb |
stosb |
cmp al, '?' |
jnz @b |
dec edi |
mov eax, [ebp+filesearch_data.list.numitems] |
push -'0' |
push 10 |
pop ecx |
@@: |
xor edx, edx |
div ecx |
push edx |
test eax, eax |
jnz @b |
@@: |
pop eax |
add al, '0' |
jz @f |
stosb |
jmp @b |
@@: |
lodsb |
stosb |
test al, al |
jnz @b |
ret |
|
filesearch_getname: |
if lang eq ru |
mov eax, '¨ «' |
stosd |
mov eax, '®£ ¯' |
stosd |
mov eax, '®¨áª' |
stosd |
mov al, ' ' |
stosb |
else |
mov eax, 'Find' |
stosd |
mov eax, ' dia' |
stosd |
mov eax, 'log ' |
stosd |
mov al, ' ' |
stosb |
end if |
ret |
|
filesearch_stop_thread: |
mov [ebp+filesearch_data.stop], 1 |
|
filesearch_wait_thread: |
mov ecx, [ebp+filesearch_data.slot] |
mov edx, [ebp+filesearch_data.tid] |
jecxz .secondary_thread_exited |
@@: |
mov ebx, procinfo |
push 9 |
pop eax |
int 40h |
cmp word [ebx+50], 9 |
jz .secondary_thread_exited |
cmp dword [ebx+30], edx |
jnz .secondary_thread_exited |
push 5 |
pop eax |
push 1 |
pop ebx |
int 40h |
jmp @b |
.secondary_thread_exited: |
and [ebp+filesearch_data.slot], 0 |
ret |
|
filesearch_OnExit: |
call filesearch_stop_thread |
call filesearch_free_result |
; call filesearch_set_dlgflags ; use it? I think, no |
ret |
|
filesearch_IsHandleUsed: |
test ebp, ebp |
ret |
|
filesearch_set_dlgflags: |
mov eax, dword [ebp+filesearch_data.query_dlgdata+filesearch_query_template.flags_case-filesearch_query_template] |
and al, 10h |
or al, 8 |
mov [find_in_file_dlgdata.flags_case], eax |
mov eax, dword [ebp+filesearch_data.query_dlgdata+filesearch_query_template.flags_whole-filesearch_query_template] |
and al, 10h |
or al, 8 |
mov [find_in_file_dlgdata.flags_whole], eax |
lea esi, [ebp+filesearch_data.string] |
mov edi, SearchString |
and dword [edi-4], 0 |
and dword [edi-8], 0 |
@@: |
lodsb |
stosb |
test al, al |
jnz @b |
ret |
|
filesearch_getcurdlg: |
lea ebx, [ebp+filesearch_data.query_dlgdata] |
cmp [ebp+filesearch_data.tid], -1 |
jz @f |
add ebx, filesearch_data.search_dlgdata - filesearch_data.query_dlgdata |
@@: |
ret |
|
filesearch_free_result: |
mov ecx, [ebp+filesearch_data.result_blocks] |
@@: |
jecxz .ret |
push dword [ecx] |
call pgfree |
pop ecx |
jmp @b |
.ret: |
ret |
|
filesearch_thread: |
pop ebp |
; initialize search for string |
xor ecx, ecx |
xor edx, edx |
mov [ebp+filesearch_data.skip_errors_mask], cl |
lea ebx, [ebp+filesearch_data.string] |
cmp byte [ebx], dl |
jz .noprepare |
mov esi, tolower_table |
test byte [ebp+filesearch_data.query_dlgdata+filesearch_query_template.flags_case-filesearch_query_template], 10h |
jz @f |
mov esi, identical_table |
@@: |
test byte [ebp+filesearch_data.query_dlgdata+filesearch_query_template.flags_whole-filesearch_query_template], 10h |
setnz al |
push eax |
push ecx ; force cp866 |
call search_string_pre |
.noprepare: |
push -1 |
.enter_recursion: |
xor esi, esi ; start position: zero |
.read_folder_loop: |
push esi |
lea esi, [ebp+filesearch_data.curdir] |
lea edi, [ebp+filesearch_data.curfile] |
@@: |
lodsb |
stosb |
test al, al |
jnz @b |
pop esi |
.read_retry: |
lea ebx, [ebp+filesearch_data.fs.func] |
mov dword [ebx], 1 |
mov dword [ebx+4], esi |
and dword [ebx+8], 0 |
mov dword [ebx+12], search_dir_query_size |
lea eax, [ebp+filesearch_data.dir_area] |
mov [ebx+16], eax |
push 70 |
pop eax |
int 40h |
test eax, eax |
jz .read_folder_ok |
cmp eax, 6 |
jz .read_folder_ok |
xor ebx, ebx |
xchg ebx, dword [ebp+filesearch_data.dir_area+4] |
test [ebp+filesearch_data.skip_errors_mask], filesearch_data.skip_read_folder |
jnz .skip1 |
push edx |
lea edx, [ebp+filesearch_data.curdir] |
call recursive_read_folder_err |
pop edx |
jz .read_retry |
cmp al, 2 |
jnz @f |
dec eax |
or [ebp+filesearch_data.skip_errors_mask], filesearch_data.skip_read_folder |
@@: |
cmp al, 1 |
jnz .cancel |
.skip1: |
.read_folder_ok: |
imul ebx, 304 |
lea eax, [ebp+filesearch_data.dir_area+32] |
add ebx, eax |
.scan_folder_loop: |
cmp eax, ebx |
jae .scan_folder_done |
; ignore special entries "." and ".." |
cmp word [eax+40], '.' |
jz .scan_folder_next |
cmp word [eax+40], '..' |
jnz @f |
cmp byte [eax+42], 0 |
jz .scan_folder_next |
@@: |
call .check_stop |
; construct name |
push esi edi ebx eax |
lea ebx, [ebp+filesearch_data.curfile+1023] |
lea esi, [eax+40] |
mov byte [edi-1], '/' |
@@: |
cmp edi, ebx |
jae .namebig |
lodsb |
stosb |
test al, al |
jnz @b |
pop eax |
test byte [eax], 10h |
jz .scan_file |
; it is nested folder, enter recursion |
; to maintain ASCIIZ string coherency, copy backward |
lea esi, [edi+filesearch_data.curdir-filesearch_data.curfile] |
@@: |
dec edi |
dec esi |
mov al, [edi] |
mov [esi], al |
cmp al, '/' |
jnz @b |
mov [ebp+filesearch_data.datachanged], 1 |
pop ebx edi |
jmp .enter_recursion |
.namebig: |
pop eax |
mov byte [edi], 0 |
test [ebp+filesearch_data.skip_errors_mask], filesearch_data.skip_bigname |
jnz .namebig.skip |
push eax |
push edi |
test byte [eax], 10h |
mov eax, aFileNameTooBig |
jz @f |
add eax, aFolderNameTooBig - aFileNameTooBig |
@@: |
push eax |
mov eax, esp |
push SkipOrCancelBtn |
push 3 |
push eax |
push 2 |
call SayErr |
cmp al, 1 |
jnz @f |
dec eax |
or [ebp+filesearch_data.skip_errors_mask], filesearch_data.skip_bigname |
@@: |
test al, al |
pop eax eax eax |
jnz .cancel |
.namebig.skip: |
jmp .scan_folder_next_pop |
.scan_file: |
; it is a file |
; first check: does file name match the mask? |
push eax edx |
; ®¡àî¥â¨âì |
lea esi, [eax+40] |
lea edi, [ebp+filesearch_data.lowername] |
push edi |
xor eax, eax |
@@: |
lodsb |
mov al, [tolower_table+eax] |
stosb |
test al, al |
jnz @b |
; ¯®¥å «¨ |
lea edx, [edi-1] |
pop esi |
lea edi, [ebp+filesearch_data.mask] |
call match_mask_rev_lowercase |
pop edx eax |
jc .scan_folder_next_pop |
; ok, second check: is the string present in this file? |
jecxz .file_found |
push eax |
call filesearch_test_file |
pop eax |
jc .scan_folder_next_pop |
.file_found: |
push eax |
; allocate memory for new result |
lea esi, [ebp+filesearch_data.curfile] |
mov ebx, esi |
@@: |
lodsb |
test al, al |
jnz @b |
sub esi, ebx |
mov eax, [ebp+filesearch_data.cur_result_ptr] |
add esi, 8 |
push ecx |
mov ecx, 0x4000 |
sub ecx, eax |
cmp ecx, esi |
jae .nonewblock |
mov ecx, 0x4000 |
call xpgalloc |
test eax, eax |
jz .cancel |
pushd [ebp+filesearch_data.result_blocks] |
popd [eax] |
mov [ebp+filesearch_data.result_blocks], eax |
push 4 |
pop eax |
mov [ebp+filesearch_data.cur_result_ptr], eax |
.nonewblock: |
add eax, [ebp+filesearch_data.result_blocks] |
add [ebp+filesearch_data.cur_result_ptr], esi |
pop ecx |
; eax -> allocated memory, fill it |
push eax |
lea edi, [eax+8] |
mov esi, ebx |
@@: |
lodsb |
stosb |
test al, al |
jnz @b |
pop eax |
mov ebx, [ebp+filesearch_data.list.end] |
mov [eax+4], ebx |
and dword [eax], 0 |
mov [ebp+filesearch_data.list.end], eax |
test ebx, ebx |
jz @f |
mov [ebx], eax |
@@: |
inc [ebp+filesearch_data.list.numitems] |
cmp [ebp+filesearch_data.list.curitemptr], 0 |
jnz @f |
mov [ebp+filesearch_data.list.curitemptr], eax |
@@: |
cmp [ebp+filesearch_data.list.head], 0 |
jnz @f |
mov [ebp+filesearch_data.list.head], eax |
@@: |
mov [ebp+filesearch_data.datachanged], 1 |
pop eax |
.scan_folder_next_pop: |
pop ebx edi esi |
mov byte [edi-1], 0 |
.scan_folder_next: |
inc esi |
add eax, 304 |
jmp .scan_folder_loop |
.scan_folder_done: |
cmp dword [ebp+filesearch_data.dir_area+4], search_dir_query_size |
jz .read_folder_loop |
pop esi |
inc esi |
jz .done |
lea eax, [ebp+filesearch_data.curdir] |
@@: |
inc eax |
cmp byte [eax], 0 |
jnz @b |
@@: |
dec eax |
cmp byte [eax], '/' |
jnz @b |
mov byte [eax], 0 |
mov [ebp+filesearch_data.datachanged], 1 |
jmp .read_folder_loop |
.cancel: |
.done: |
mov [ebp+filesearch_data.datachanged], 2 |
or eax, -1 |
int 40h |
|
.check_stop: |
cmp [ebp+filesearch_data.stop], 1 |
jz .cancel |
ja @f |
ret |
@@: |
push eax ebx |
push 5 |
pop eax |
push 1 |
pop ebx |
int 40h |
pop ebx eax |
jmp .check_stop |
|
filesearch_test_file: |
lea ebx, [ebp+filesearch_data.fs.func] |
lea eax, [ebp+filesearch_data.filebuf] |
mov [ebx+16], eax |
xor eax, eax |
mov [ebx], eax |
mov [ebx+4], eax |
mov [ebx+8], eax |
mov dword [ebx+12], search_filebuf_size |
mov edi, edx |
test byte [ebp+filesearch_data.query_dlgdata+filesearch_query_template.flags_whole-filesearch_query_template], 10h |
jz .loop |
add edi, 256 |
.loop: |
.read_retry: |
call filesearch_thread.check_stop |
push 70 |
pop eax |
lea ebx, [ebp+filesearch_data.fs.func] |
int 40h |
test eax, eax |
jz .readok |
cmp eax, 6 |
jz .readok |
test [ebp+filesearch_data.skip_errors_mask], filesearch_data.skip_read_file |
jnz .ret_failed |
push edx |
lea edx, [ebp+filesearch_data.curfile] |
call recursive_read_file_err |
pop edx |
jz .read_retry |
cmp al, 2 |
jnz @f |
dec eax |
or [ebp+filesearch_data.skip_errors_mask], filesearch_data.skip_read_file |
@@: |
cmp al, 1 |
jnz filesearch_thread.cancel |
.ret_failed: |
stc |
ret |
.readok: |
test ebx, ebx |
jz .eof |
push ebx |
lea esi, [ebp+filesearch_data.filebuf] |
add ebx, esi |
; edi = current state, edx -> FSM, ecx = last state, |
; esi -> current data, ebx -> end of buffer |
.scanloop: ; loop unrolled |
; get current symbol |
movzx eax, byte [esi] |
; calculate next state |
movzx edi, byte [edi+eax] |
; done? |
cmp edi, ecx |
jz .ret_ok_pop |
; no; proceed to next symbol |
shl edi, 8 |
add edi, edx |
cmp esi, ebx |
jae .scandone |
movzx eax, byte [esi+1] |
add esi, 2 |
movzx edi, byte [edi+eax] |
cmp edi, ecx |
jz .ret_ok_pop |
shl edi, 8 |
add edi, edx |
cmp esi, ebx |
jb .scanloop |
.scandone: |
pop ebx |
.eof: |
add [ebp+filesearch_data.fs.pos_low], ebx |
adc [ebp+filesearch_data.fs.pos_high], 0 |
cmp ebx, search_filebuf_size |
jz .loop |
; EOF, last chance for whole-words-only search |
test byte [ebp+filesearch_data.query_dlgdata+filesearch_query_template.flags_whole-filesearch_query_template], 10h |
jz .ret_failed |
movzx edi, byte [edi+' '] |
cmp edi, ecx |
jnz .ret_failed |
clc |
ret |
.ret_ok_pop: |
pop ebx |
clc |
ret |
|
virtual at 0 |
_FILE: |
.pos dq ? |
.bufpos dq ? |