From 5d0b189266cd645dbe79a4ec3c216f07ea768cb1 Mon Sep 17 00:00:00 2001 From: Alex Borisov Date: Sat, 3 Dec 2011 16:25:42 +0200 Subject: FIX app not terminated when config.cfg do not exist --- client/main.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'client/main.cpp') diff --git a/client/main.cpp b/client/main.cpp index 9e85eb4..9fd9c58 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -1,13 +1,40 @@ +#include /* defines FILENAME_MAX */ +#ifdef WINDOWS + #include + #define GetCurrentDir _getcwd +#else + #include + #define GetCurrentDir getcwd +#endif +#include + +#include +#include #include "ProxyClientApp.h" #include "client.h" -#include "Dialog.h" ProxyClientApp *this_app; int main(int argc, char *argv[]) { Logger::Info("Starting client application\n"); - this_app = new ProxyClientApp(argc, argv); + char currentPath[FILENAME_MAX]; + if (! GetCurrentDir(currentPath, sizeof(currentPath))) + { + return errno; + } + // check if initial config exists (config.cfg) + // without it application is useless + QString configPath = QString::fromLocal8Bit(currentPath) + "/config.cfg"; + QFileInfo configInfo(configPath); + if (! configInfo.exists()) + { + Logger::Fatal("Initial configuration file (config.cfg) do not exist!\n"); + Logger::Fatal("Terminating!\n"); + return -1; + } + + this_app = new ProxyClientApp(argc, argv); return this_app->exec(); } -- cgit v1.2.3