From bedbe3caad680f2aeb0fc9bbabd95f8d55d49d06 Mon Sep 17 00:00:00 2001
From: ehofman <ehofman>
Date: Sun, 18 Dec 2005 09:37:37 +0000
Subject: [PATCH] Frederic: this patch to sg_path.cxx will filter out false
 alarms when directory already exists.

---
 simgear/misc/sg_path.cxx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/simgear/misc/sg_path.cxx b/simgear/misc/sg_path.cxx
index 4f709d1c..a72175ab 100644
--- a/simgear/misc/sg_path.cxx
+++ b/simgear/misc/sg_path.cxx
@@ -221,9 +221,13 @@ void SGPath::create_dir( mode_t mode ) {
     }
 #endif
     struct stat info;
-    for(; stat( dir.c_str(), &info ) == 0 && i < path_elements.size(); i++) {
+    int r;
+    for(; ( r = stat( dir.c_str(), &info ) ) == 0 && i < path_elements.size(); i++) {
         dir.append(path_elements[i]);
     }
+    if ( r == 0 ) {
+        return; // Directory already exists
+    }
     if ( sgMkDir( dir.c_str(), mode) ) {
         SG_LOG( SG_IO, SG_ALERT, "Error creating directory: " + dir.str() );
         return;
-- 
2.39.5