From 6579fdd0858bf099f735f45e35ba065983e55ca7 Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Fri, 8 Nov 2013 00:48:28 +0000 Subject: [PATCH] -Fixed issue with save paths, now adheres to NSM standard saving mechanisms --- src/diskreader.cxx | 8 ++++---- src/diskwriter.cxx | 15 +++++++++++---- src/gui.cxx | 7 ++++--- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/diskreader.cxx b/src/diskreader.cxx index 0036721..4b30a41 100644 --- a/src/diskreader.cxx +++ b/src/diskreader.cxx @@ -51,7 +51,7 @@ int DiskReader::loadPreferences() cJSON* ctlrs = cJSON_GetObjectItem( preferencesJson, "defaultControllers" ); if ( ctlrs ) { - //cout << ".nanba HAS items." << endl; + //cout << ".ctlr HAS items." << endl; int nCtlrs = cJSON_GetArraySize( ctlrs ); for(int i = 0; i < nCtlrs; i++ ) { @@ -69,7 +69,7 @@ int DiskReader::loadPreferences() } else { - cout << "Warning: .nanba has no items." << endl; + LUPPP_NOTE("No default controllers active."); } cJSON_Delete( preferencesJson ); @@ -223,10 +223,10 @@ int DiskReader::readSession( std::string path ) s << path << "/session.luppp"; stringstream samplePath; - samplePath << path << "/samples/sample.cfg"; + samplePath << path << "/audio/audio.cfg"; cout << "session path: " << s.str() << endl; - cout << "sample path: " << samplePath.str() << endl; + cout << "audio path: " << samplePath.str() << endl; // open session, read all std::ifstream file( s.str().c_str(), std::ios_base::in|std::ios_base::ate); diff --git a/src/diskwriter.cxx b/src/diskwriter.cxx index 28afbd8..05d3444 100644 --- a/src/diskwriter.cxx +++ b/src/diskwriter.cxx @@ -37,27 +37,34 @@ void DiskWriter::initialize(std::string path, std::string name ) // write session.luppp JSON node to /.luppp stringstream sessionDirStream; - sessionDirStream << path << "/" << sessionName; + + sessionDirStream << path; + + if ( !gui->getNsm() ) + sessionDirStream << "/" << sessionName; + sessionDir = sessionDirStream.str(); + LUPPP_NOTE( "Creating session dir %s", sessionDir.c_str() ); + int sessionDirError = mkdir( sessionDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH ); if ( sessionDirError ) { // handle by using different filename? - LUPPP_WARN("%s","Error creating session directory"); + LUPPP_WARN("Error creating session directory"); } stringstream audioDirStream; audioDirStream << sessionDir << "/audio"; audioDir = audioDirStream.str(); - LUPPP_NOTE("%s %s","Creating audio dir ", audioDir.c_str() ); + LUPPP_NOTE("Creating audio dir %s", audioDir.c_str() ); int audioDirError = mkdir( audioDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH ); // FIXME: error check mkdir for error return if ( audioDirError ) { - LUPPP_WARN("%s","Error creating sample directory"); + LUPPP_WARN("Error creating sample directory"); } foldersCreated = true; diff --git a/src/gui.cxx b/src/gui.cxx index 995901a..dfb03d2 100644 --- a/src/gui.cxx +++ b/src/gui.cxx @@ -237,10 +237,11 @@ static int cb_nsm_open (const char *name, Jack::setup( client_id ); - + stringstream loadPath; + loadPath << name; // load the NSM provided directory - gui->getDiskReader()->readSession( name ); + gui->getDiskReader()->readSession( loadPath.str() ); // initialize the disk-writer to the same directory: // we *always* overwrite the old save file when using NSM @@ -251,7 +252,7 @@ static int cb_nsm_open (const char *name, static int cb_nsm_save ( char **out_msg, void *userdata ) { - LUPPP_NOTE("NSM: saving session as %s", *out_msg ); + LUPPP_NOTE("NSM: saving..." ); // disk-writer already initialized to the right directory, so just write! EventStateSave e;