]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/sg_dir.cxx
hla: Use HLADataElementIndices for HLAInteractionClass.
[simgear.git] / simgear / misc / sg_dir.cxx
index a9969e07089cf8e37581eaa274f317d95093266f..0aea771bfd004f6926fe25abbc1f373ca0031f40 100644 (file)
@@ -23,6 +23,8 @@
 #endif
 
 #include <simgear/misc/sg_dir.hxx>
+#include <math.h>
+#include <stdlib.h>
 
 #ifdef _WIN32
 #  define WIN32_LEAN_AND_MEAN
@@ -40,7 +42,9 @@
 #include <boost/foreach.hpp>
 
 #include <cstring>
+#include <cstdlib>
 #include <iostream>
+#include <algorithm> // for std::sort
 
 using std::string;
 
@@ -121,6 +125,11 @@ Dir Dir::tempDir(const std::string& templ)
 #endif
 }
 
+static bool pathSortPredicate(const SGPath& p1, const SGPath& p2)
+{
+  return p1.file() < p2.file();
+}
+
 PathList Dir::children(int types, const std::string& nameFilter) const
 {
   PathList result;
@@ -238,6 +247,11 @@ PathList Dir::children(int types, const std::string& nameFilter) const
   
   closedir(dp);
 #endif
+
+  // File system order is random. Make things deterministic,
+  // so it's the same for every user.
+  std::sort(result.begin(), result.end(), pathSortPredicate);
+
   return result;
 }