0

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?

Jørgen R
  • 10,568
  • 7
  • 42
  • 59
sxingfeng
  • 971
  • 4
  • 15
  • 32

2 Answers2

1

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

Community
  • 1
  • 1
default
  • 11,485
  • 9
  • 66
  • 102
  • 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
0

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
  • 173,980
  • 10
  • 155
  • 350