Skip to content

Commit

Permalink
Allow storing script output to absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
gzotti committed Jun 13, 2018
1 parent 1fc06cd commit 485abf8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/scripting/StelScriptOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,18 @@ void StelScriptOutput::saveOutputAs(const QString &name)
QFile asFile;
QFileInfo outputInfo(outputFile);
QDir dir=outputInfo.dir(); // will hold complete dirname
QFileInfo newFileNameInfo(name);
//QDir newFileDir=newFileNameInfo.dir();

if (newFileNameInfo.fileName()==name)
{
asFile.setFileName(dir.absolutePath() + "/" + name);
}
else
{
asFile.setFileName(name);
}

asFile.setFileName(dir.absolutePath() + "/" + name);
if (!asFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text | QIODevice::Unbuffered))
{
qDebug() << "ERROR: Cannot open file" << dir.absolutePath() + "/" + name;
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/StelScriptOutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class StelScriptOutput

//! Save to new file, re-create output file.
//! This allows reading of results on Windows, where otherwise reading programs cannot access files opened for writing by Stellarium.
//! @param name new filename. It will be created in the same directory as output.txt
//! @param name new filename. If this is not an absolute path, it will be created in the same directory as output.txt
//! Normally you would call saveOutputAs(...), then reset().
static void saveOutputAs(const QString& name);

Expand Down

0 comments on commit 485abf8

Please sign in to comment.