Skip to content

Commit

Permalink
Use data directory in portable mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sgourdas committed Aug 23, 2024
1 parent 92163b5 commit 99abf1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/kiwixapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ void KiwixApp::newTab()
QString KiwixApp::findLibraryDirectory()
{
auto currentDataDir = QString::fromStdString(kiwix::removeLastPathElement(kiwix::getExecutablePath()));
auto portableFile = QFileInfo(currentDataDir, ".portable");
if (portableFile.exists())
return currentDataDir + "/data";

// Check for library.xml in the same directory as the executable.
auto libraryFile = QFileInfo(currentDataDir, "library.xml");
if (libraryFile.exists())
Expand Down
5 changes: 5 additions & 0 deletions src/settingsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

QString getDataDirectory()
{
auto currentDataDir = QString::fromStdString(kiwix::removeLastPathElement(kiwix::getExecutablePath()));
auto portableFile = QFileInfo(currentDataDir, ".portable");
if (portableFile.exists())
return currentDataDir + "/data";

QString dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);

if (!dataDir.isEmpty() && QDir().mkpath(dataDir))
Expand Down

0 comments on commit 99abf1f

Please sign in to comment.