From e8b15b394c89816b83dd53022881795972eca8f0 Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Sun, 8 Jan 2017 11:29:42 +0000 Subject: [PATCH] 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. --- src/diskwriter.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/diskwriter.cxx b/src/diskwriter.cxx index f70a53e..6830549 100644 --- a/src/diskwriter.cxx +++ b/src/diskwriter.cxx @@ -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 /.luppp stringstream sessionDirStream;