I want to scan FAT32 disk (I just need file path and file name) as soon as possible in C++, Scan every files on FAT32 disk. Is there any API to do this?
2 Answers
Check this thread: How can I quickly enumerate directories on Win32?
It actually describes FindFirstFile/FindNextFile, but if you need it faster you should go Kernel.
The index solution described in the thread will however not work for FAT32 systems - credit MSalters
-
Note that the index solution hinted at in your thread assumes NTFS chnage journals; the FAT32 in this topic excludes that option. – MSalters Mar 30 '10 at 13:42
-
thanks MSalters. I changed my answer to include this. Although, my main reason to post this was to check the other thread out :) – default Mar 30 '10 at 14:27
The term "scanning" isn't very well defined. Do you want to read each and every byte of each and every file? The easiest way is to use a directory list. Start by pushing the root directory. Then, as long as the directory list is not empty, call FindFirstFile/FindNextFile
to enumerate all files and subdirectories. Add subdirectories to the directory list, and read the files you encounter.
Update: For your purposes, FindFirstFileEx(FindExInfoBasic)
would suffice. You still would want to process only a single directory at a time (breadth-first) instead of entering subdirectories as soon as you see them (depth-first). This is faster because FAT32 directory entries in a single directory are stored together, but subdirectories are typically not stored adjacent to the parent directories.

- 173,980
- 10
- 155
- 350