summaryrefslogtreecommitdiffstats
path: root/src/fbgui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fbgui.cpp')
-rw-r--r--src/fbgui.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index fe67b79..825af9c 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -6,6 +6,9 @@
#include <getopt.h>
#include <fbgui.h>
+#include <string>
+#include <limits.h>
+#include <unistd.h>
void printUsage()
{
@@ -20,14 +23,11 @@ void printUsage()
exit(1);
}
-QString getPath(const char* c)
+std::string getPath()
{
- QString appPath = c;
- // Locate last '/' in the full path and remove all the chars after it.
- appPath.chop(appPath.length() - 1
- - appPath.lastIndexOf("/", appPath.length()-1));
- qDebug() << "Application path: " << appPath;
- return appPath;
+ char result[ PATH_MAX ];
+ size_t count = readlink("/proc/self/exe", result, PATH_MAX);
+ return std::string( result, (count > 0) ? count : 0);
}
int main(int argc, char *argv[])
@@ -59,12 +59,13 @@ int main(int argc, char *argv[])
}
opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
}
+ // Get the application path and prints on screen.
+ std::string appPath = getPath();
+ std::cout << "Application path: " << appPath << endl;
// This is the main object of a QT Application.
QApplication a(argc, argv);
// Is this really needed, since we kill the app through the fbbrowser object?
QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
- // Get the application path.
- QString appPath = getPath(argv[0]);
// This part reads the URL to load from the arguments given through the commandline.
QUrl url;
if (argc > 1)