From 7f76d7bc3029729a6b02b87bac1529a83d8d83f4 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 23 Jun 2017 13:09:59 +0200 Subject: [PATCH] Added ability for file recording to create parent directories first --- src/output/output.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/output/output.cpp b/src/output/output.cpp index 4057e1e5..db9257b0 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "output.h" namespace Mist{ @@ -1088,6 +1089,10 @@ namespace Mist{ bool Output::connectToFile(std::string file){ int flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; int mode = O_RDWR | O_CREAT | O_TRUNC; + if (!Util::createPathFor(file)){ + ERROR_MSG("Cannot not create file %s: could not create parent folder", file.c_str()); + return false; + } int outFile = open(file.c_str(), mode, flags); if (outFile < 0){ ERROR_MSG("Failed to open file %s, error: %s", file.c_str(), strerror(errno));