|
|
|
|
@ -15,7 +15,6 @@
|
|
|
|
|
#include <cstdio> |
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
#include <QStandardPaths> |
|
|
|
|
#include <QTemporaryFile> |
|
|
|
|
#include <windows.h> |
|
|
|
|
#include <tlhelp32.h> |
|
|
|
|
#endif |
|
|
|
|
@ -90,17 +89,13 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
QString cfgDir = QCoreApplication::applicationDirPath(); |
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
QString storageReason; |
|
|
|
|
if (!QFile::exists(cfgDir + "/vibechat.cfg") && !QFile::exists(cfgDir + "/chatgui.cfg")) { |
|
|
|
|
storageReason = QStringLiteral("config missing in executable directory"); |
|
|
|
|
} else { |
|
|
|
|
/* Реальная проверка записи учитывает ACL Windows, а не только атрибуты каталога. */ |
|
|
|
|
QTemporaryFile probe(cfgDir + "/.vibechat-write-XXXXXX"); |
|
|
|
|
if (!probe.open()) { |
|
|
|
|
storageReason = QStringLiteral("executable directory is not writable: %1").arg(probe.errorString()); |
|
|
|
|
} else if (!probe.remove()) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "Cannot remove write probe %s: %s", |
|
|
|
|
qPrintable(probe.fileName()), qPrintable(probe.errorString())); |
|
|
|
|
return 1; |
|
|
|
|
{ |
|
|
|
|
/* Проверяем существующий конфиг без создания, обрезки или изменения содержимого. */ |
|
|
|
|
QFile configFile(cfgDir + "/vibechat.cfg"); |
|
|
|
|
if (!configFile.exists()) { |
|
|
|
|
storageReason = QStringLiteral("config missing in executable directory"); |
|
|
|
|
} else if (!configFile.open(QIODevice::ReadWrite | QIODevice::ExistingOnly)) { |
|
|
|
|
storageReason = QStringLiteral("config is not writable: %1").arg(configFile.errorString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!storageReason.isEmpty()) { |
|
|
|
|
@ -111,7 +106,7 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
storageReason = QStringLiteral("config found in writable executable directory"); |
|
|
|
|
storageReason = QStringLiteral("writable config found in executable directory"); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|