]> git.mxchange.org Git - simgear.git/commitdiff
HTTPFileRequest: create directory if it does not exist
authorThomas Geymayer <tomgey@gmail.com>
Mon, 28 Oct 2013 11:38:39 +0000 (12:38 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Mon, 28 Oct 2013 11:38:39 +0000 (12:38 +0100)
simgear/io/HTTPFileRequest.cxx

index e5cc71d6e12c58468f4ae5e5547a3e747913fdbd..33b7339a78185c9631290ddfdaafc18dbf158ab8 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "HTTPFileRequest.hxx"
 #include <simgear/debug/logstream.hxx>
+#include <simgear/misc/sg_path.hxx>
 
 namespace simgear
 {
@@ -38,9 +39,14 @@ namespace HTTP
     Request::responseHeadersComplete();
 
     if( !_filename.empty() )
+    {
       // TODO validate path? (would require to expose fgValidatePath somehow to
       //      simgear)
+      SGPath path(_filename);
+      path.create_dir(0777);
+
       _file.open(_filename.c_str(), std::ios::binary | std::ios::trunc);
+    }
 
     if( !_file )
     {