Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enumerating Files from the filesystem

Status
Not open for further replies.

Milleniumlegend

IS-IT--Management
Dec 16, 2003
135
Could someone please let me know how to enumerate files under a directory in a filesystem. I would like to get a list of files from the filesystem under a particular directory recursively. I would need to make the search as fast as possible.

Many Thanks
 
Open a directory with opendir(), then continue reading files using readdir() until it returns NULL. If you want to get the sub-directories also, call stat() on the filename to determine if it's a file or directory; then if it's a directory call your directory enumeration function again with the sub-directory appended to the original name... Don't forget to call closedir() for each call you make to opendir() when you're finished.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top