mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-23 12:00:21 -04:00
+ Launcher can be now launched from one level directory hight than before
This commit is contained in:
parent
81155937d4
commit
9fce067a3e
@ -22,27 +22,40 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "pathTools.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
/* Initialisation of a few paths */
|
||||
string executablePath = getExecutablePath();
|
||||
string executableDirectory = removeLastPathElement(executablePath);
|
||||
string applicationIniPath = computeAbsolutePath(executableDirectory, "application.ini");
|
||||
|
||||
/* Possible xulrunner paths */
|
||||
std::vector<std::string> xulrunnerPossibleDirectories;
|
||||
xulrunnerPossibleDirectories.push_back("xulrunner");
|
||||
xulrunnerPossibleDirectories.push_back("kiwix/xulrunner");
|
||||
xulrunnerPossibleDirectories.push_back("kiwix-linux/xulrunner");
|
||||
xulrunnerPossibleDirectories.push_back("kiwix-win/xulrunner");
|
||||
xulrunnerPossibleDirectories.push_back("kiwix-windows/xulrunner");
|
||||
|
||||
/* Find xulrunner directory */
|
||||
string xulrunnerDirectory = computeAbsolutePath(executableDirectory, "xulrunner");
|
||||
if (!fileExists(xulrunnerDirectory)) {
|
||||
xulrunnerDirectory = computeAbsolutePath(executableDirectory, "kiwix");
|
||||
xulrunnerDirectory = computeAbsolutePath(executableDirectory, "xulrunner");
|
||||
string xulrunnerDirectory;
|
||||
std::vector<std::string>::iterator directoriesIt = xulrunnerPossibleDirectories.begin();
|
||||
while (xulrunnerDirectory.empty() && directoriesIt != xulrunnerPossibleDirectories.end()) {
|
||||
xulrunnerDirectory = computeAbsolutePath(executableDirectory, *directoriesIt);
|
||||
if (!fileExists(xulrunnerDirectory)) {
|
||||
perror("Unable to find the xulrunner directory");
|
||||
return EXIT_FAILURE;
|
||||
xulrunnerDirectory.clear();
|
||||
directoriesIt++;
|
||||
}
|
||||
}
|
||||
if (!fileExists(xulrunnerDirectory)) {
|
||||
perror("Unable to find the xulrunner directory");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Find xulrunner binary path */
|
||||
string xulrunnerPath = computeAbsolutePath(xulrunnerDirectory, "xulrunner-bin");
|
||||
@ -54,6 +67,9 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute application.ini path */
|
||||
string applicationIniPath = computeAbsolutePath(removeLastPathElement(xulrunnerDirectory, false, false), "application.ini");
|
||||
|
||||
/* Debug prints */
|
||||
/*
|
||||
cout << "Executable directory (executableDirectory): " << executableDirectory << endl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user