]> 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 c575c053a82235ec67111563166fb1f113a237f2..0aea771bfd004f6926fe25abbc1f373ca0031f40 100644 (file)
@@ -44,6 +44,7 @@
 #include <cstring>
 #include <cstdlib>
 #include <iostream>
+#include <algorithm> // for std::sort
 
 using std::string;
 
@@ -124,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;
@@ -241,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;
 }