Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 directories
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Andy




PostPosted: Thu Apr 20, 2006 12:03 pm   Post subject: directories

any one know a way to list the contents of a directory into an array for windows? i'm using VC++ 6.0.

thanks
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Thu Apr 20, 2006 12:32 pm   Post subject: (No subject)

okay yeah i think i have a solution to my own problem...

according to my boss, there is a windows ddk function called FindFirstFile, also i could do a system call system("dir > *.dmp contents.txt") then parse that file and delete it at the end.
Mazer




PostPosted: Thu Apr 20, 2006 12:38 pm   Post subject: (No subject)

There's a solution. I wouldn't have thought to do that only because I'm so unfamiliar with the windows command line...
I'd probably still prefer to use some system call though.
Andy




PostPosted: Thu Apr 20, 2006 12:41 pm   Post subject: (No subject)

but creating a text file then parsing it is too much of an hassle...
Mazer




PostPosted: Thu Apr 20, 2006 3:51 pm   Post subject: (No subject)

Maybe you're being sarcastic, but I do agree with what you said. That's why I'd have recommended using some winapi or other external function (sorry, I probably shouldn't have used the term "system call"). They provide lots of functionality, and you won't be able to avoid them forever... if you wanted useful things built into the language you should try something else. Python, for instance, has functions in the os module somewhere that deals with directories.
sorry about dave, I couldn't resist
wtd




PostPosted: Thu Apr 20, 2006 4:17 pm   Post subject: (No subject)

Research the following fucntions.

FindFirstFile, FindFirstFileEx, FindNextFile, FindClose
md




PostPosted: Thu Apr 20, 2006 5:29 pm   Post subject: (No subject)

If your using system calls and temporary files then I don't wanna see your code... that's just plain wrong. MSDN is your friend for windows APIs...
wtd




PostPosted: Thu Apr 20, 2006 5:37 pm   Post subject: (No subject)

Alternatively, you could use the Boost libraries, which provide abstractions around the native OS' API calls.

http://boost.org/libs/filesystem/doc/index.htm
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Thu Apr 20, 2006 7:53 pm   Post subject: (No subject)

Heh, Andy: Very Happy
Andy




PostPosted: Fri Apr 21, 2006 10:39 am   Post subject: (No subject)

wtd, if you read my second post, i already stated that my boss gave me a solution. but thanks for your help anyways.

i encountered boost, but you had to include like 4 different headers.. i'm really bloody lazy, and this is just an OCA bucket collection tool, and since OCA is by microsoft, i dont need cross platform
wtd




PostPosted: Fri Apr 21, 2006 11:45 am   Post subject: (No subject)

Yeah. I saw that. I just thought I'd expand on it by offering a few additional function names to research. If nothing else I figured it'd make it easier to run searches for example code. Smile

Oh, and don't discount Boost. You may not need it to be cross-platform, but Boost is likely also a great deal easier to use.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: