diff options
Diffstat (limited to 'client/main.cpp')
-rw-r--r-- | client/main.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/client/main.cpp b/client/main.cpp index a1904ae..4b6d734 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -1,39 +1,37 @@ -#include <stdio.h> #ifdef WINDOWS - #include <direct.h> - #define GetCurrentDir _getcwd #define UpdaterName "updater.exe" + #define PathSlash "\\" #else - #include <unistd.h> - #define GetCurrentDir getcwd #define UpdaterName "updater" + #define PathSlash "/" #endif -#include <errno.h> #include <QFileInfo> #include <QProcess> #include <QString> +#include <string> #include "ProxyClientApp.h" #include "client.h" +using std::string; + ProxyClientApp *this_app; int main(int argc, char *argv[]) { Logger::Info("Starting client application\n"); - char currentPath[FILENAME_MAX]; - if (! GetCurrentDir(currentPath, sizeof(currentPath))) - { - return errno; - } - QString cwd = currentPath; - // check if client should be updated - QFileInfo newClient(cwd + "/client.bin.latest"); + string path = argv[0]; + size_t p = path.find_last_of(PathSlash); + QString dir = QString::fromStdString(path.substr(0, p)); + Logger::Trace("Application path: %s\n", dir.toStdString().c_str()); + + // check if client should be update + QFileInfo newClient(dir + PathSlash + "client.bin.latest"); if (newClient.exists()) { Logger::Info("New client version found!\n"); - QString updater = cwd + "/" UpdaterName; + QString updater = dir + PathSlash + UpdaterName; if (QProcess::startDetached(updater)) { Logger::Info("Updater launched\n"); @@ -47,7 +45,7 @@ int main(int argc, char *argv[]) // check if initial config exists (config.cfg) // without it application is useless - QFileInfo configInfo(cwd + "/config.cfg"); + QFileInfo configInfo(dir + PathSlash + "config.cfg"); if (! configInfo.exists()) { Logger::Fatal("Initial configuration file (config.cfg) do not exist!\n"); |