-Fixed issue with save paths, now adheres to NSM standard saving mechanisms

main
Harry van Haaren 2013-11-08 00:48:28 +00:00
parent 0a9471cf54
commit 6579fdd085
3 changed files with 19 additions and 11 deletions

View File

@ -51,7 +51,7 @@ int DiskReader::loadPreferences()
cJSON* ctlrs = cJSON_GetObjectItem( preferencesJson, "defaultControllers" ); cJSON* ctlrs = cJSON_GetObjectItem( preferencesJson, "defaultControllers" );
if ( ctlrs ) if ( ctlrs )
{ {
//cout << ".nanba HAS items." << endl; //cout << ".ctlr HAS items." << endl;
int nCtlrs = cJSON_GetArraySize( ctlrs ); int nCtlrs = cJSON_GetArraySize( ctlrs );
for(int i = 0; i < nCtlrs; i++ ) for(int i = 0; i < nCtlrs; i++ )
{ {
@ -69,7 +69,7 @@ int DiskReader::loadPreferences()
} }
else else
{ {
cout << "Warning: .nanba has no items." << endl; LUPPP_NOTE("No default controllers active.");
} }
cJSON_Delete( preferencesJson ); cJSON_Delete( preferencesJson );
@ -223,10 +223,10 @@ int DiskReader::readSession( std::string path )
s << path << "/session.luppp"; s << path << "/session.luppp";
stringstream samplePath; stringstream samplePath;
samplePath << path << "/samples/sample.cfg"; samplePath << path << "/audio/audio.cfg";
cout << "session path: " << s.str() << endl; cout << "session path: " << s.str() << endl;
cout << "sample path: " << samplePath.str() << endl; cout << "audio path: " << samplePath.str() << endl;
// open session, read all // open session, read all
std::ifstream file( s.str().c_str(), std::ios_base::in|std::ios_base::ate); std::ifstream file( s.str().c_str(), std::ios_base::in|std::ios_base::ate);

View File

@ -37,27 +37,34 @@ void DiskWriter::initialize(std::string path, std::string name )
// write session.luppp JSON node to <path>/<sessionName>.luppp // write session.luppp JSON node to <path>/<sessionName>.luppp
stringstream sessionDirStream; stringstream sessionDirStream;
sessionDirStream << path << "/" << sessionName;
sessionDirStream << path;
if ( !gui->getNsm() )
sessionDirStream << "/" << sessionName;
sessionDir = sessionDirStream.str(); 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 ); int sessionDirError = mkdir( sessionDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
if ( sessionDirError ) if ( sessionDirError )
{ {
// handle by using different filename? // handle by using different filename?
LUPPP_WARN("%s","Error creating session directory"); LUPPP_WARN("Error creating session directory");
} }
stringstream audioDirStream; stringstream audioDirStream;
audioDirStream << sessionDir << "/audio"; audioDirStream << sessionDir << "/audio";
audioDir = audioDirStream.str(); 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 ); int audioDirError = mkdir( audioDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
// FIXME: error check mkdir for error return // FIXME: error check mkdir for error return
if ( audioDirError ) if ( audioDirError )
{ {
LUPPP_WARN("%s","Error creating sample directory"); LUPPP_WARN("Error creating sample directory");
} }
foldersCreated = true; foldersCreated = true;

View File

@ -237,10 +237,11 @@ static int cb_nsm_open (const char *name,
Jack::setup( client_id ); Jack::setup( client_id );
stringstream loadPath;
loadPath << name;
// load the NSM provided directory // load the NSM provided directory
gui->getDiskReader()->readSession( name ); gui->getDiskReader()->readSession( loadPath.str() );
// initialize the disk-writer to the same directory: // initialize the disk-writer to the same directory:
// we *always* overwrite the old save file when using NSM // 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 ) 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! // disk-writer already initialized to the right directory, so just write!
EventStateSave e; EventStateSave e;