Projects > MasmBasic & the RichMasm IDE

Get Files and GetFolders

(1/3) > >>

clamicun:
Boa noite jj,
Here is one which doesn't let me sleep.

2 methods to search for files on a disk/folder.

1. GetMyFiles uses the macro GetFiles
GetFiles "C:\*.xxx"

2. GetMyFolders uses the macro GetFolders
GetFolders "C:\"
Then it uses INVOKE FindFirstFile,"offset Files$(ecx)",offset wfd

GetFiles is faster but GetFolders has the advantage that you only have to use it once searching the same disk/folder.
The next times you can use the saved results. Files$(ecx) and and the amount of folders. So then it is much faster. 

My problem.
The results are "mostly" the same, but not always !
We know that. An error is an error, you have to find it, but sometimes error and sometimes not is always bad.

It seems that searching for any textfiles (*.txt *.doc *.htm *.pdf and others)  is correct
Searching *.exe *.dll *.sys and others can produce different results.

After a couple of days experimenting  now I have to ask you if you could take a look on the two sources.
No hurry. 
My machine is Win7 32b.



 
 

jj2007:

--- Quote from: clamicun on August 20, 2017, 08:41:22 AM ---GetFiles is faster but GetFolders has the advantage that you only have to use it once searching the same disk/folder.
The next times you can use the saved results. Files$(ecx) and and the amount of folders. So then it is much faster.
...
Searching *.exe *.dll *.sys and others can produce different results.
--- End quote ---

Hi Clamicun,

2. I made some quick tests, see screenshots below, and the result is an identical count of exe and dll files.
1. The three boxes are in chronological order, and you can see that GetFolders is very slow indeed, but only the first time. Afterwards, everything is in the cache, so GetFiles and GetFolders are about equally fast.

Problems with exe, sys and dll files can have several causes (and they are most likely not a problem of the algo!), but to investigate, one would have to see which files exactly have not been found on your machine. A simple Store "GetFiles.txt", Files$() may help.

Btw the little apps are well done :t

P.S.: I just see that you do save the results. Post the ones that differ...

clamicun:
jj,
thanks.
Here is a screenshot.
I'll try to check which *.exe are lacking.

jj2007:

--- Quote from: clamicun on August 21, 2017, 02:26:02 AM ---I'll try to check which *.exe are lacking.
--- End quote ---

That will be difficult because you save in MyFolders.txt the folder names only, in MyFiles.txt the file names...

On my machine, the difference is 8 files among 17,000, 0.047%, see screenshot.
idden and read-only files seem not affected, the count is equal for both applications.
But one culprit is already identified: Your FindFirstFile will not find files with non-Latin alphabet names. GetFiles() is Unicode aware, filenames are returned in UTF8 format.

However, that doesn't explain why your folders.exe finds more files for my drive C: :(

What comes to my mind is "super hidden" files, or double-counting, e.g. because of links. But really, without identifying which files are not found in either application, there is no chance to find the reason.

clamicun:
Quote jj "That will be difficult because you save in MyFolders.txt the folder names only, in MyFiles.txt the file names"

I know. That's why I said  "I'll try to find".
But anyway I'll try and let you know.

btw.you have patience .. 741 seconds is a lot.

Navigation

[0] Message Index

[#] Next page

Go to full version