this way works ok and is small but i think
its slow cause i switch from dir to dir with
setcurrentdir... anyone knows a better way?

  

.DATA
FILE_MASK DB "*", 0
BACK DB "..", 0
TESTFILE DB "TEST.TXT", 0
BLA DB 13, 10

.DATA?
BUFFER DB 100 DUP ( ? )
W32FD WIN32_FIND_DATA < ? >
S_HANDLE DD ?
TESTHANDLE DD ?

.CODE
START: INVOKE _lcreat, ADDR TESTFILE, 0
MOV TESTHANDLE, EAX
CALL SCAN_DRIVES
INVOKE _lclose, TESTHANDLE
INVOKE ExitProcess, 0

SCAN_DRIVES:
INVOKE GetLogicalDriveStrings, 100, ADDR BUFFER
MOV EDI, OFFSET BUFFER
LOOP_: INVOKE GetDriveType, EDI ; - use this to search only on fixed
CMP EAX, DRIVE_FIXED ; drives or if you want to search only
JNZ BLAHHH ; a spezifed drive just set the current
; dir to the root and call SCAN_DIR not
; SCAN_DRIVES!!!
INVOKE SetCurrentDirectory, EDI
PUSH OFFSET BLAHHH

SCAN_DIR:
INVOKE FindFirstFile, ADDR FILE_MASK, ADDR W32FD
INC EAX
JZ _S_OUT
DEC EAX
MOV S_HANDLE, EAX
_S_SCAN:CMP W32FD.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY
JNZ NO_DIR
CMP BYTE PTR [ W32FD.cFileName ], "."
JZ NEXT_
INVOKE SetCurrentDirectory, ADDR W32FD.cFileName
PUSH S_HANDLE
CALL SCAN_DIR
POP S_HANDLE
JMP NEXT_
NO_DIR: INVOKE lstrlen, ADDR W32FD.cFileName
INVOKE _lwrite, TESTHANDLE, ADDR W32FD.cFileName, EAX
INVOKE _lwrite, TESTHANDLE, ADDR BLA, 2
NEXT_: INVOKE FindNextFile, S_HANDLE, ADDR W32FD
TEST EAX, EAX
JNZ _S_SCAN
INVOKE SetCurrentDirectory, ADDR BACK
INVOKE FindClose, S_HANDLE
_S_OUT: RET

BLAHHH: ADD EDI, 4
CMP BYTE PTR [ EDI ], 0
JNZ LOOP_
RET
END START


thank you...
Posted on 2001-12-04 20:06:55 by mob
I believe findfirst/nextfile support paths too, like "C:\Windows\*.txt".
Posted on 2001-12-05 00:57:58 by Qweerdy
I usually do it recursively, and keep track of the "current dir" in a local
variable. When entering the scan function, I pass it a path and a
mask. When you need to enter a new directory, copy the path
argument to a temporary buffer, add a backslash and the directory
you want to enter, and call the scan function recursively.
Posted on 2001-12-05 09:18:00 by f0dder
Posted on 2001-12-05 17:35:09 by bitRAKE