I am tryingto find all files/directories with given mask.I wrote below proc but it gives two times directory name.What I am doing wrong here ?


m1 db "*.*",0
p1 db "C:\My Documents\",0
sls db "\",0
invoke ZipFilesWithMask,addr p1,addr m1,0,0,1,0
invoke ExitProcess,eax

ZipFilesWithMask proc Path:DWORD,Msk:DWORD,Method:DWORD,Cmnt:DWORD,Recur:DWORD,CallBack:DWORD

invoke lstrcpy,addr tBuff,Path
invoke lstrcat,addr tBuff, Msk
invoke FindFirstFile,addr tBuff, addr wc
mov hFind,eax
.while eax !=0
.if byte ptr wc.cFileName != '.'
.if wc.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY
.if Recur
invoke lstrcpy,addr tBuff2,Path
invoke lstrcat,addr tBuff2,addr wc.cFileName
invoke lstrcat,addr tBuff2,addr sls
invoke ZipFilesWithMask,addr tBuff2,Msk,Method,Cmnt,Recur,CallBack
invoke MessageBox,0,addr [wc].cFileName,0,MB_OK
invoke FindNextFile,hFind,addr wc
ZipFilesWithMask endp
end start

Edit: My problem is in the *proc*. Anyway I added Exitprocess
Posted on 2002-11-10 07:03:22 by LaptoniC
you need something like
invoke ZipFilesWithMask,addr p1,addr m1,0,0,1,0
xor eax,eax
invoke ExitProcess,eax

ZipFilesWithMask etc.
Posted on 2002-11-10 07:10:19 by argus
hmm :/

some pointers: check for "..", if I remember correctly windows also gives the previous dir.

also I don't think your routine recurses correctly since it will go into the first directory it finds and won't bother with any others should they be there.

I think I have a directory routine here somewhere on the board. I'll look.
Posted on 2002-11-10 07:39:14 by Hiroshimator
damn don't think I put up the actual dir recursor.

best way would be to

get the first dir, loop through files

if it's a directory add its path to a directory linked list
if it's a file process it or add it to another (file) list

when you reach the end of the filesfound, get the last directory from your directory linked list (don't forget to remove it or mark it as processed) and repeat the process until all entries in your directories list are used or removed.

my dir with subdirs 1 and 2 who each have subdir sub will yield

dir list

when you process 1
dir list

so eventually you'll get everything :)

also when looking for files with a certain extension: you can't recurse when looking for one unless your directories end with the same extension AFAIK (it's been long since I did something similar :| )

I hope this helps you on your way
Posted on 2002-11-10 07:49:19 by Hiroshimator
It works on my computer .. I get all the files. I couldn't see any directory twice .. if I didn't overlook something.

But I would also test for hidden( FILE_ATTRIBUTE_HIDDEN ) and/or system( FILE_ATTRIBUTE_SYSTEM ) files and not display those ... of course that is personnal perference.
Posted on 2002-11-10 10:48:06 by gorshing
My mistake :tongue: In my computer there was a file which has same name with directory.Thanks for the test
Posted on 2002-11-10 12:24:07 by LaptoniC
Iam trying to write zlib wrapper.I want tomake a function which will zip all files with given directory and mask.I can find all files with mask with the help of findfirstfile and findnextfile apis.I want to add files according to base folder.In zip files if there is directory it ends with /.Therefore anyfile in the directory have / in their name.Because my function is recursive I dont know how to determine relative path and keep track of base folder.Any help will be appreciated.

[]-C:\My Documents
[]-Sub Folder1
[]-Sub Folder2

I want to get relative paths and files according to base folder.ie

add file1
add file2
createdir Sub Folder1
add file Sub Folder1/subfile1
add file Sub Folder2/subfile2
createdir Sub Folder1/Sub Folder2
add file Sub Folder1/Sub Folder2/subfile3
add file Sub Folder1/Sub Folder2/subfile4
Posted on 2002-11-11 08:27:23 by LaptoniC