]> git.mxchange.org Git - simgear.git/commitdiff
Convert _filename to an SGPath
authorErik Hofman <erik@ehofman.com>
Sat, 2 Jul 2016 09:03:32 +0000 (11:03 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 13 Aug 2016 08:21:16 +0000 (10:21 +0200)
simgear/io/HTTPFileRequest.cxx
simgear/io/HTTPFileRequest.hxx

index 460216252ff897a492d74c518d10791cf697c0a2..2a6d226f58c99b6b0c9e73a5edcf4f2e13f48100 100644 (file)
@@ -41,14 +41,13 @@ namespace HTTP
     if( responseCode() != 200 )
       return setFailure(responseCode(), responseReason());
 
-    if( !_filename.empty() )
+    if( !_filename.isNull() )
     {
       // TODO validate path? (would require to expose fgValidatePath somehow to
       //      simgear)
-      SGPath path(_filename);
-      path.create_dir(0755);
+      _filename.create_dir(0755);
 
-      _file.open(_filename.c_str(), std::ios::binary | std::ios::trunc);
+      _file.open(_filename.c_str(), std::ios::binary | std::ios::trunc | std::ios::out);
     }
 
     if( !_file )
index 43d1cbd5efa2af8a59405c3185ea88ec5597adb5..9eaf727987a8d902673aa3a74e7339c30a0cf38b 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef SG_HTTP_FILEREQUEST_HXX_
 #define SG_HTTP_FILEREQUEST_HXX_
 
+#include <simgear/misc/sg_path.hxx>
 #include "HTTPRequest.hxx"
 #include <fstream>
 
@@ -43,7 +44,7 @@ namespace HTTP
       FileRequest(const std::string& url, const std::string& path);
 
     protected:
-      std::string   _filename;
+      SGPath _filename;
       std::ofstream _file;
 
       virtual void responseHeadersComplete();