View Single Post
Join Date: Apr 2008
Posts: 47
Reputation: Cybulski is an unknown quantity at this point 
Solved Threads: 3
Cybulski's Avatar
Cybulski Cybulski is offline Offline
C++ wannabe

Re: Iterator assertion failure. How?

 
0
  #6
May 16th, 2008
Ok, here is my solution:

  1. int DirectoryReader::MakeList(string p_sPath)
  2. {
  3. cout << "Parameter: " << p_sPath << endl;
  4. struct _finddatai64_t struct_filedata;
  5. string s_filename = p_sPath + "\\*.*";
  6. string s_current = ".";
  7. string s_parrent = "..";
  8.  
  9. cout << "Listing " << s_filename << endl;
  10.  
  11. long nHandle = _findfirsti64(s_filename.c_str(), &struct_filedata);
  12. if(nHandle >= 0)
  13. {
  14. while(_findnexti64(nHandle, &struct_filedata) == 0)
  15. {
  16. if(struct_filedata.attrib & _A_SUBDIR)
  17. {
  18. if( (s_current.compare(struct_filedata.name) && s_parrent.compare(struct_filedata.name)) )
  19. {
  20. s_filename = p_sPath + "\\" + struct_filedata.name;
  21. cout << "Subdir found: " << s_filename << endl;
  22. MakeList(s_filename);
  23. }
  24. else
  25. {
  26. cout << "Dir found: " << struct_filedata.name << endl;
  27. }
  28. }
  29. else
  30. {
  31. cout << "File found: " << struct_filedata.name << endl;
  32. m_vFilenames.push_back(struct_filedata.name);
  33. }
  34.  
  35. }
  36. }
  37. else
  38. {
  39. cout << "Path not found." << endl;
  40. return -1;
  41. }
  42.  
  43.  
  44. return 1;
  45. }

Two things bother me:
1) strcmp() don't want take data.name as first parameter,
2) "." should be found and displayed, but it isn't.

It works well besides that.
Last edited by Cybulski; May 16th, 2008 at 9:48 am.
Reply With Quote