问题
I'm writing a program that searches through the entire file system by file name and file contents (plain text). Is there any algorithm or open source project that could make the search very fast? I'm doing this on Windows with FAT/NTFS
file systems and I don't want indexing.
回答1:
Downloaded a NTFS searcher (named NTFS-Search) on SourceForce and it does the job very well! It first reads the 'FAT'once and after that it is incredibly fast. Only the interface is in German.
You can download the source with SVN:
svn co https://ntfs-search.svn.sourceforge.net/svnroot/ntfs-search
回答2:
If you're only searching by file name / file attributes / file date, the "magic" method to have the best performances is to manually "parse" the File Allocation Table (if filesystem is FAT) and the Master File Table (if filesystem is NTFS).
It's not too hard for the FAT filesystem as it's quite simple and well documented, but it's more difficult for NTFS, as the filesystem is much more complicated and not-so-well documented.
If you also want to search for file content, then there is no way but enumerating all files the reading through their content. You'll always be limited by the disk read speed, you can't optimize that without indexing file content.
来源:https://stackoverflow.com/questions/11824325/fast-search-on-fat32-ntfs-file-system