Skip to content

Commit

Permalink
Revise: make exporter temporary files be a sub-directory of a Mudlet …
Browse files Browse the repository at this point in the history
…one (Mudlet#5358)

On some OSes the temporary files location in the file system is shared so
it is beneficial for all the Mudlet specific ones to be in a Mudlet
sub-directory.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
  • Loading branch information
SlySven authored Aug 10, 2021
1 parent 6492c4a commit d5f74a3
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/dlgPackageExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,18 @@ void dlgPackageExporter::slot_export_package()
// if packageName changed allow to create a new package in the same path
mPackagePathFileName = QStringLiteral("%1/%2.mpackage").arg(getActualPath(), mPackageName);

QString tempDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);

QString stagingDirName = QStringLiteral("%1/%2").arg(tempDir, mPackageName);
// QT Docs say that QStandardPaths::writableLocation(QStandardPaths::TempLocation)
// "Returns a directory where temporary files can be stored. The returned
// value might be application-specific, shared among other applications for
// this user, or even system-wide. The returned path is never empty."
// which will return something like:
// Windows: "C:/Users/<USER>/AppData/Local/Temp"
// Linux: "/tmp"
// MacOS: randomly generated by the OS
// To avoid confusion if the user looks in that part of their file-system we
// will append a "/mudlet" suffix so they can see that we are interested in
// those files:
QString stagingDirName = QStringLiteral("%1/mudlet/%2").arg(QStandardPaths::writableLocation(QStandardPaths::TempLocation), mPackageName);
QDir packageDir = QDir(stagingDirName);
if (!packageDir.exists()) {
packageDir.mkpath(stagingDirName);
Expand All @@ -473,8 +482,7 @@ void dlgPackageExporter::slot_export_package()
packageDir.mkpath(stagingDirName);
}

QString tempPath = stagingDirName;
tempPath.append("/");
QString tempPath = QStringLiteral("%1/").arg(stagingDirName);

mExportingPackage = true;
QApplication::setOverrideCursor(Qt::BusyCursor);
Expand Down

0 comments on commit d5f74a3

Please sign in to comment.