Skip to content

Commit

Permalink
cd() to tmp dir when starting OMShellGUI
Browse files Browse the repository at this point in the history
  • Loading branch information
hkiel committed Sep 27, 2017
1 parent a172806 commit 7519ad7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions OMShell/OMShellGUI/main.cpp
Expand Up @@ -101,6 +101,21 @@ int main(int argc, char *argv[])
translator.load(locale, dir);
app.installTranslator(&translator);

env->evalExpression(QString("setCommandLineOptions(\"+d=shortOutput\")"));
// Avoid cluttering the whole disk with omc temp-files
QString tmpDir = env->TmpPath();
if (!QDir().exists(tmpDir)) QDir().mkdir(tmpDir);
tmpDir = QDir(tmpDir).canonicalPath();
//std::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", QString("Could not create or cd to temp-dir\nCommand:\n %1\nReturned:\n %2").arg(tmpDir).arg(cdRes));
exit(1);
}

OMS oms;
oms.show();

Expand Down

0 comments on commit 7519ad7

Please sign in to comment.