Skip to content

Commit

Permalink
- During startup, switch the omc working directory to TEMP/{OMShell,O…
Browse files Browse the repository at this point in the history
…MNotebook}/ so we have a directory with write access

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8032 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Feb 26, 2011
1 parent 04b7dc0 commit 41fbce9
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions OMNotebook/OMNotebookQT4/cellapplication.cpp
Expand Up @@ -146,17 +146,18 @@ namespace IAEX
// try to start it
// 2006-02-09 AF, Start of OMC have been moved to omcineractice-
// environment
OmcInteractiveEnvironment* omcEnv;
try
{
OmcInteractiveEnvironment* zz = OmcInteractiveEnvironment::getInstance();
OmcInteractiveEnvironment* omcEnv = OmcInteractiveEnvironment::getInstance();
}
catch( exception &e )
{
e.what();
if( !OmcInteractiveEnvironment::startOMC() )
{
QMessageBox::critical( 0, "OMC Error", "Was unable to start OMC, OMNotebook will therefore be unable to evaluate Modelica expressions." );
//exit( -1 );
exit( -1 );
}
}

Expand All @@ -178,6 +179,24 @@ namespace IAEX
exit(1);
}

// Avoid cluttering the whole disk with omc temp-files
OmcInteractiveEnvironment *env = OmcInteractiveEnvironment::getInstance();
QString getTempStr = "getTempDirectoryPath()";
env->evalExpression( getTempStr );
QString tmpDir = env->getResult()+"/OMNotebook/";
tmpDir.remove("\"");
if (!QDir().exists(tmpDir)) QDir().mkdir(tmpDir);
tmpDir = QDir(tmpDir).canonicalPath();
cout << "Temp.Dir " << tmpDir.toStdString() << std::endl;
QString cdCmd = "cd(\"" + tmpDir + "\")";
env->evalExpression(cdCmd);
QString cdRes = env->getResult();
cdRes.remove("\"");
if (0 != tmpDir.compare(cdRes)) {
QMessageBox::critical( 0, "OpenModelica Error", "Could not create or cd to temp-dir\nCommand:\n "+tmpDir+"\nReturned:\n "+cdRes);
exit(1);
}

// 2006-02-13 AF, create temp dir
if( !dir.exists( "OMNotebook_tempfiles" ) )
dir.mkdir( "OMNotebook_tempfiles" );
Expand Down

0 comments on commit 41fbce9

Please sign in to comment.