扫描 FAT32 磁盘中文件的最快方法是什么?
我想用C++尽快扫描FAT32磁盘(我只需要文件路径和文件名), 扫描 FAT32 磁盘上的每个文件。 有没有API可以做到这一点?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查此线程:如何快速枚举 Win32 上的目录?
它实际上描述了FindFirstFile/FindNextFile,但如果你需要更快,你应该去内核。
然而,线程中描述的索引解决方案不适用于 FAT32 系统 - 归功于 MSalters
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
“扫描”一词的定义并不明确。您想读取每个文件的每个字节吗?最简单的方法是使用目录列表。首先推送根目录。然后,只要目录列表不为空,就调用
FindFirstFile/FindNextFile
枚举所有文件和子目录。将子目录添加到目录列表中,并读取遇到的文件。更新:对于您的目的,
FindFirstFileEx(FindExInfoBasic)
就足够了。您仍然希望一次仅处理一个目录(广度优先),而不是一看到子目录就进入它们(深度优先)。这更快,因为单个目录中的 FAT32 目录条目存储在一起,但子目录通常不存储在与父目录相邻的位置。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.