fix #163; save file dir parent dir created

Previously when not using NSM, and the project dir ~/luppp/
did not exist, Luppp would fail to save the session as it did
not attempt to create the directory. This patch adds the creating
of the directory if it does not already exist.
main
Harry van Haaren 2017-01-08 11:29:42 +00:00
parent 394ced7f33
commit e8b15b394c
1 changed files with 11 additions and 0 deletions

View File

@ -95,6 +95,17 @@ void DiskWriter::initialize(std::string path, std::string name )
sessionName = name;
sessionPath = path;
/* If project dir doesn't exist yet, create it */
int projectDir = mkdir( path.c_str(),
S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
if ( errno == EEXIST ) {
//LUPPP_NOTE("project dir %s exists, this is good", path.c_str());
} else if ( projectDir ) {
LUPPP_WARN("Error creating projectDir: %s", strerror(errno));
} else {
LUPPP_NOTE("Creating %s directory", path.c_str());
}
// write session.luppp JSON node to <path>/<sessionName>.luppp
stringstream sessionDirStream;