News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Get files list on a directory

Started by Farabi, December 28, 2010, 10:17:29 AM

Previous topic - Next topic

Farabi

Anyone know how to generate a files list on a directory?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"


BogdanOntanu

Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

jj2007

Bogdan, he is an experienced programmer who is brave enough to be lazy. So I offered him the lazy solution :bg

Farabi

Quote from: jj2007 on December 28, 2010, 11:40:02 AM
Bogdan, he is an experienced programmer who is brave enough to be lazy. So I offered him the lazy solution :bg

Sorry, I did not really understand about recursive one, always wasting my stack  :green
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

dedndave

if you just want the files in the current directory - and not the subdirectories - you don't need a recursive routine
still - enumerating files is one of the best applications of recursion - and a good place to learn it   :U

whether you use recursion or not, FindFirst and FindNext are the functions you need
they are pretty easy to use
one of the few things that is almost the same as old DOS programming   :bg

Vortex

Hi Onan,

Here is a quick example for you :


include     ListFiles.inc

.data

FileName    db '*.*',0
f1          db '%s',13,10,0

.data?

wfd         WIN32_FIND_DATA <?>
hFind       dd ?
buffer      db MAX_PATH + 4 dup(?)

FName       equ OFFSET wfd + WIN32_FIND_DATA.cFileName

.code

start:

    invoke  FindFirstFile,ADDR FileName,ADDR wfd
    cmp     eax,INVALID_HANDLE_VALUE
    je      _exit

    mov     hFind,eax
@@:
    invoke  wsprintf,ADDR buffer,ADDR f1,FName
    invoke  StdOut,ADDR buffer

    invoke  FindNextFile,hFind,ADDR wfd
    test    eax,eax
    jnz     @b

_exit:

    invoke  FindClose,hFind

    invoke  ExitProcess,0

END start

Farabi

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"