Jump to content
  • Advertisement
Sign in to follow this  
RSC_x

best way to store all filelist of system on c++?

This topic is 3996 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i wonder what is the best way for storing all the shstem file list on c/c.. i tryed <list> style but i hawe some problems.i think it does not store char's can anyone answer what is the best/secure/stable way to store all the lists. list <char*> looks easy but somehow it does not work. or is it acceptable to use char arrays. i think someones can write here a list /vector style pointer sample which works for findfirs/next file paths... thanks..

Share this post


Link to post
Share on other sites
Advertisement
If you are storing a collection of strings then either:

std::list< std::string > >

std::vector< std::string > >

Is what you are looking for. You could use a map instead if you wanted fast look up etc. Generally when working with strings we use std::string.

Dave

Share this post


Link to post
Share on other sites
FindFirstFile and FindNextFile return their data in a WIN32_FIND_DATA structure, with the filename present in the .cFileName member, which happens to be TCHAR[MAX_PATH]. TCHAR, in turn, is a preprocessor substitution identifier for either char or one of several wide-character representations depending on whether UNICODE is set.

What you want to do is:
  1. use std::list< std::vector< TCHAR > > to store a vector of characters, but this is quite inflexible;

  2. switch off UNICODE and use std::list< std::string> >;

  3. convert your filenames to ASCII for insertion into the list using WideCharToMultiByte; or

  4. use std::list< std::wstring >

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!