]> git.mxchange.org Git - flightgear.git/commitdiff
Workaround for problem with SGPath: create_dir() does not create the last subdirector...
authorDurk Talsma <durktals@gmail.com>
Thu, 14 May 2015 15:41:58 +0000 (17:41 +0200)
committerDurk Talsma <durktals@gmail.com>
Thu, 14 May 2015 15:41:58 +0000 (17:41 +0200)
src/Traffic/TrafficMgr.cxx

index c4abd836426d65ff0b007fdf61903c9f305ae717..e17c801cfa03824cf7c5f081895da932b574dcd5 100644 (file)
@@ -454,14 +454,21 @@ void FGTrafficManager::shutdown()
             ::snprintf(buffer, 128, "%c/%c/%c/",
                        airport[0], airport[1], airport[2]);
             cacheData.append(buffer);
+            cacheData.append(airport + "-cache.txt");
+            
+            // Note: Intuitively, this doesn't make sense, but I do need to create the full file path first
+            // before creating the directories. The SimGear fgpath code has changed so that it first chops off
+            // the trailing dir separator and then determines the directory part of the file path by searching
+            // for the last dir separator. Effecively, this causes a full element of the directory tree to be
+            // skipped. 
+            SG_LOG(SG_GENERAL, SG_DEBUG, "Trying to create dir for : " << cacheData.c_str());
             if (!cacheData.exists()) {
                 cacheData.create_dir(0755);
             }
-            cacheData.append(airport + "-cache.txt");
-            //cerr << "Saving AI traffic heuristics" << endl;
             saveData = true;
             cachefile.open(cacheData.str().c_str());
             cachefile << "[TrafficManagerCachedata:ref:2011:09:04]" << endl;
+            
         }
     }