Sign in to follow this  
RSC_x

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

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this