]> 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 7d26025b05c97f6e20c66052415eca4bf182f557..0aea771bfd004f6926fe25abbc1f373ca0031f40 100644 (file)
@@ -42,7 +42,9 @@
 #include <boost/foreach.hpp>
 
 #include <cstring>
+#include <cstdlib>
 #include <iostream>
+#include <algorithm> // for std::sort
 
 using std::string;
 
@@ -123,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;
@@ -240,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;
 }