HTTPFileRequest: create directory if it does not exist
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "HTTPFileRequest.hxx"
|
#include "HTTPFileRequest.hxx"
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
|
||||||
namespace simgear
|
namespace simgear
|
||||||
{
|
{
|
||||||
@@ -38,9 +39,14 @@ namespace HTTP
|
|||||||
Request::responseHeadersComplete();
|
Request::responseHeadersComplete();
|
||||||
|
|
||||||
if( !_filename.empty() )
|
if( !_filename.empty() )
|
||||||
|
{
|
||||||
// TODO validate path? (would require to expose fgValidatePath somehow to
|
// TODO validate path? (would require to expose fgValidatePath somehow to
|
||||||
// simgear)
|
// simgear)
|
||||||
|
SGPath path(_filename);
|
||||||
|
path.create_dir(0777);
|
||||||
|
|
||||||
_file.open(_filename.c_str(), std::ios::binary | std::ios::trunc);
|
_file.open(_filename.c_str(), std::ios::binary | std::ios::trunc);
|
||||||
|
}
|
||||||
|
|
||||||
if( !_file )
|
if( !_file )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user