]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/HTTPFileRequest.cxx
Remove SVN sync code.
[simgear.git] / simgear / io / HTTPFileRequest.cxx
index e5cc71d6e12c58468f4ae5e5547a3e747913fdbd..460216252ff897a492d74c518d10791cf697c0a2 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "HTTPFileRequest.hxx"
 #include <simgear/debug/logstream.hxx>
+#include <simgear/misc/sg_path.hxx>
 
 namespace simgear
 {
@@ -37,10 +38,18 @@ namespace HTTP
   {
     Request::responseHeadersComplete();
 
+    if( responseCode() != 200 )
+      return setFailure(responseCode(), responseReason());
+
     if( !_filename.empty() )
+    {
       // TODO validate path? (would require to expose fgValidatePath somehow to
       //      simgear)
+      SGPath path(_filename);
+      path.create_dir(0755);
+
       _file.open(_filename.c_str(), std::ios::binary | std::ios::trunc);
+    }
 
     if( !_file )
     {
@@ -50,8 +59,6 @@ namespace HTTP
         SG_WARN,
         "HTTP::FileRequest: failed to open file '" << _filename << "'"
       );
-
-      abort("Failed to open file.");
     }
   }
 
@@ -63,8 +70,8 @@ namespace HTTP
       SG_LOG
       (
         SG_IO,
-        SG_WARN,
-        "HTTP::FileRequest: error writing to '" << _filename << "'"
+        SG_DEBUG,
+        "HTTP::FileRequest: received data for closed file '" << _filename << "'"
       );
       return;
     }