mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-24 04:20:56 -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 <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "pathTools.h"
|
#include "pathTools.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
/* Initialisation of a few paths */
|
/* Initialisation of a few paths */
|
||||||
string executablePath = getExecutablePath();
|
string executablePath = getExecutablePath();
|
||||||
string executableDirectory = removeLastPathElement(executablePath);
|
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 */
|
/* Find xulrunner directory */
|
||||||
string xulrunnerDirectory = computeAbsolutePath(executableDirectory, "xulrunner");
|
string xulrunnerDirectory;
|
||||||
if (!fileExists(xulrunnerDirectory)) {
|
std::vector<std::string>::iterator directoriesIt = xulrunnerPossibleDirectories.begin();
|
||||||
xulrunnerDirectory = computeAbsolutePath(executableDirectory, "kiwix");
|
while (xulrunnerDirectory.empty() && directoriesIt != xulrunnerPossibleDirectories.end()) {
|
||||||
xulrunnerDirectory = computeAbsolutePath(executableDirectory, "xulrunner");
|
xulrunnerDirectory = computeAbsolutePath(executableDirectory, *directoriesIt);
|
||||||
if (!fileExists(xulrunnerDirectory)) {
|
if (!fileExists(xulrunnerDirectory)) {
|
||||||
perror("Unable to find the xulrunner directory");
|
xulrunnerDirectory.clear();
|
||||||
return EXIT_FAILURE;
|
directoriesIt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!fileExists(xulrunnerDirectory)) {
|
||||||
|
perror("Unable to find the xulrunner directory");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Find xulrunner binary path */
|
/* Find xulrunner binary path */
|
||||||
string xulrunnerPath = computeAbsolutePath(xulrunnerDirectory, "xulrunner-bin");
|
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 */
|
/* Debug prints */
|
||||||
/*
|
/*
|
||||||
cout << "Executable directory (executableDirectory): " << executableDirectory << endl;
|
cout << "Executable directory (executableDirectory): " << executableDirectory << endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user