I would like to know about the FindFirstFile and the following first FindNextFile. Is it true, that FindFirstFile ALWAYS find the '.' (current folder) and the following FindNextFile ALWAYS the '..' (parent folder)? The mask of course is '*'. I want a little speed up file listing, could I write something, like:
h := FindFirstFile('path\*' ...) // it finds '.', not process
if h = INVALID_HANDLE_VALUE then ... // some error handling, of course
FindNextFile(...) // skipping '..', I suppose, if '.' has found,
// '..' will be too, no handle validity check
while FindNextFile(...) do
// file/folder processing begins here
So I don't need checking '.' and '..' filenames in every cycle. Sorry for the syntax, I think, I was understandable, and for my english, if I made mistakes.
There is no guarantee at all that the first two entries will be '. ' and '..'. So your proposed code cannot be used.
You could, I suppose, keep a track in a boolean of whether or not you have seen these two entries and if so skip the checks.
However, checking for these values is not your bottleneck. Enumerating directories involves trips to the disk and system calls. That is the bottleneck. Any attempt to optimise checking for these items will obfuscate your code and yield no discernible performance benefit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With