From f28a388c9952961e870bf036ec0e28f4737ed21f Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 27 Jan 2011 12:52:03 +0100 Subject: changed getPath() function, now uses /proc/self/exe to get the path. --- src/fbbrowser.cpp | 2 +- src/fbgui.cpp | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/fbbrowser.cpp b/src/fbbrowser.cpp index bd2eb8e..5495a78 100644 --- a/src/fbbrowser.cpp +++ b/src/fbbrowser.cpp @@ -6,7 +6,7 @@ void fbbrowser::httpReadyRead() { // This slot listens to readyRead() signal from our QNetworkReply. - qDebug() << "readyRead() signal emmited!" << endl; + qDebug() << "finished() signal emmited!" << endl; if(reply->error() == QNetworkReply::NoError) { qDebug() << "No error, loading given URL..."; 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 #include +#include +#include +#include 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) -- cgit v1.2.3-55-g7522