Advertisement
Guest User

file sorting for maratis

a guest
Jun 24th, 2012
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. Index: trunk/dev/MSDK/MCore/Sources/MFileTools.cpp
  2. ===================================================================
  3. --- trunk/dev/MSDK/MCore/Sources/MFileTools.cpp (revision 102)
  4. +++ trunk/dev/MSDK/MCore/Sources/MFileTools.cpp (working copy)
  5. @@ -35,6 +35,9 @@
  6.  #include <sys/stat.h>
  7.  #include <stdarg.h>
  8.  
  9. +#include <algorithm> // For sorting the file lists.
  10. +#include <string.h>
  11. +
  12.  #ifdef WIN32
  13.     #include <direct.h>
  14.     #define mkdir _mkdir
  15. @@ -45,6 +48,13 @@
  16.  
  17.  static MFileOpenHook* s_fileOpenHook = 0;
  18.  
  19. +// Helper function for helping sort filenames.
  20. +bool case_insensitive_lt(const string& left, const string& right)
  21. +{
  22. +   // Return true if left should come earlier than right.
  23. +   int casecmp = strcasecmp(left.c_str(), right.c_str());
  24. +   return (casecmp >= 0)? true : false;
  25. +}
  26.  
  27.  bool copyFile(const char * inFilename, const char * outFilename)
  28.  {
  29. @@ -281,6 +291,10 @@
  30.      }
  31.  
  32.      closedir(pdir);
  33. +
  34. +   // Sort the directory list alphabetically.
  35. +   sort(files->begin(), files->end());
  36. +
  37.      return true;
  38.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement