8 ms·
In theory there could be some FindFiles() that just returns an array of files. But how would you handle the memory to pass that data? The convention is that the
by wongarsu 8y ago
In theory there could be some FindFiles() that just returns an array of files. But how would you handle the memory to pass that data? The convention is that the caller allocates and owns the memory (for example you pass FindFirstFile a FIND_DATA structure to write the result into). But you don't know in advance how many files FindFiles() will return. It's not even trivial to have another API that tells you how many files FindFiles will return, because between two API calls files can be created and deleted by anyone on the system. The other option is to allocate some space, and if it wasn't enough ask for the rest of the data. And that's basically what FindFile() and FindNextFile() implement.