Added ability for file recording to create parent directories first
This commit is contained in:
parent
5a4cb100fa
commit
7f76d7bc30
1 changed files with 5 additions and 0 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include <mist/defines.h>
|
#include <mist/defines.h>
|
||||||
#include <mist/http_parser.h>
|
#include <mist/http_parser.h>
|
||||||
#include <mist/timing.h>
|
#include <mist/timing.h>
|
||||||
|
#include <mist/util.h>
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
|
|
||||||
namespace Mist{
|
namespace Mist{
|
||||||
|
@ -1088,6 +1089,10 @@ namespace Mist{
|
||||||
bool Output::connectToFile(std::string file){
|
bool Output::connectToFile(std::string file){
|
||||||
int flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
|
int flags = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
|
||||||
int mode = O_RDWR | O_CREAT | O_TRUNC;
|
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);
|
int outFile = open(file.c_str(), mode, flags);
|
||||||
if (outFile < 0){
|
if (outFile < 0){
|
||||||
ERROR_MSG("Failed to open file %s, error: %s", file.c_str(), strerror(errno));
|
ERROR_MSG("Failed to open file %s, error: %s", file.c_str(), strerror(errno));
|
||||||
|
|
Loading…
Add table
Reference in a new issue