views:

144

answers:

3

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? Many thanks!

A: 

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.

MSalters
+1  A: 

Check this thread: http://stackoverflow.com/questions/2511672/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

Default
Note that the index solution hinted at in your thread assumes NTFS chnage journals; the FAT32 in this topic excludes that option.
MSalters
thanks MSalters. I changed my answer to include this. Although, my main reason to post this was to check the other thread out :)
Default
A: 

Reverse engineer StrongRecovery for NTFS/FAT/FAT32 file recovery, it's really fast and reliable and works fine either for Windows 2000/XP/Vista/7 :P

http://www.strongrecovery.com

It's not legal but it should help you ;)

Bartosz Wójcik