Reading all files from a given directory
Hello.
Can someone please post the code/functions I need in order to loop through all the files in a directory? The directory is specified as a pathname (c:/directory), and I would like to be able to loop through the files it contains, and construct "FILE" objects for them (they will be converted to CFile objects later, so if there is a more direct route, that would be good too).
thanks for your help.
Check and see if the functions: opendir(), readdir() and closedir() or findfirst() and findnext() exist in your compiler (none of them are ANSI compatible you see). If they exist, you can use them to get a directory listing (remember that the first two files in any directory are "." and "..").
Edited by - Muzzafarath on August 14, 2000 3:15:23 PM
Edited by - Muzzafarath on August 14, 2000 3:15:23 PM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
quote: Original post by Muzzafarath
Check and see if the functions: opendir(), readdir() and closedir() or findfirst() and findnext() exist in your compiler (none of them are ANSI compatible you see).
They are POSIX 1003.1 compatibile, and this is "quite" enough to guess that most current C/C++ compilers support them.
Karmalaa.
---[home page] [[email=karmalaa@inwind.it]e-mail[/email]]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement