| 55 | QMutex m_mutex; |
| 56 | |
| 57 | QString getApplicationDirectoryPath(const char * firstCmdArgument) |
| 58 | { |
| 59 | QFileInfo fileInfo(firstCmdArgument); |
| 60 | QString appDirPath = fileInfo.absoluteDir().absolutePath(); |
| 61 | |
| 62 | QString lightpackMainConfPath = appDirPath + "/main.conf"; |
| 63 | |
| 64 | cout << lightpackMainConfPath.toStdString() << endl; |
| 65 | |
| 66 | if (QFile::exists(lightpackMainConfPath)) |
| 67 | { |
| 68 | /// Portable version |
| 69 | /// Store logs and settings in application directory |
| 70 | |
| 71 | cout << "Portable version" << endl; |
| 72 | } |
| 73 | else |
| 74 | { |
| 75 | /// Unportable version |
| 76 | /// Store logs and settings in home directory of the current user |
| 77 | |
| 78 | cout << "Unportable version" << endl; |
| 79 | |
| 80 | QString home = QDir::homePath(); |
| 81 | QString normalizedHome = home.endsWith("/") ? home.left(home.size() - 1) : home; |
| 82 | |
| 83 | # ifdef Q_OS_WIN |
| 84 | appDirPath = normalizedHome + "/Prismatik"; |
| 85 | # else |
| 86 | appDirPath = normalizedHome + "/.Prismatik"; |
| 87 | # endif |
| 88 | |
| 89 | QDir dir(appDirPath); |
| 90 | if (dir.exists() == false) |
| 91 | { |
| 92 | cout << "mkdir " << appDirPath.toStdString() << endl; |
| 93 | if (dir.mkdir(appDirPath) == false) |
| 94 | { |
| 95 | cerr << "Failed mkdir '" << appDirPath.toStdString() << "' for application generated stuff. Exit." << endl; |
| 96 | exit(LightpackApplication::AppDirectoryCreationFail_ErrorCode); |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | cout << "Application directory: " << appDirPath.toStdString() << endl; |
| 102 | |
| 103 | return appDirPath; |
| 104 | } |
| 105 | |
| 106 | void openLogsFile(const QString & appDirPath) |
| 107 | { |