11 File finder

 

Back in ancient times, one of the most popular MS-DOS utilities I wrote was the Fast File Finder. It wasn’t particularly fast, of course. But it did the job of finding a file anywhere on the PC’s hard drive when given a filename. This program was included on the companion floppy diskettes provided with many of my early computing books. Yes, floppy diskettes.

In today’s operating systems, finding files is a big deal. Both Windows and Mac OS X feature powerful file-finding tools, locating files by not only name but also date, size, and content. The Linux command prompt offers its own slate of file-finding tools, just as powerful (if not more so) as their graphical counterparts. For a budding C programmer, or anyone desiring to build their C kung fu, using these tools is useful, but you can’t improve your programming skills by just using the tools.

Hunting for files, and potentially doing something with them, relies upon the directory-spelunking tools covered in chapter 10. From this base, you can expand your knowledge of C by:

  • Reviewing other file-finding utilities
  • Exploring methods for finding text
  • Locating files in a directory tree
  • Using wildcards to match files
  • Finding filename duplicates

11.1 The great file hunt

11.2 A file finder

11.2.1 Coding the Find File utility

11.2.2 Understanding the glob

11.2.3 Using wildcards to find files

11.3 The duplicate file finder

11.3.1 Building a file list

11.3.2 Locating the duplicates