From 8f84f3ce3ab4f8342d51e6151d319458874a694d Mon Sep 17 00:00:00 2001 From: dranik Date: Fri, 24 Apr 2026 09:30:49 +0300 Subject: [PATCH] fix path Windows --- service/server/xray.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/service/server/xray.cpp b/service/server/xray.cpp index e4dee0b3c..9cdf78231 100644 --- a/service/server/xray.cpp +++ b/service/server/xray.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -53,12 +54,23 @@ bool Xray::startXray(const QString &cfg) // Temporary aid for manual verification of SOCKS auth (inbounds.settings.accounts). // Debug: always writes. Release: set env AMNEZIA_SAVE_XRAY_CONFIG=1 (if the daemon inherits it). { + QString debugPath; + #ifdef Q_OS_WIN - const QString debugPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) - + QStringLiteral("/amnezia-xray-config.json"); + const QString dirPath = QStringLiteral("C:/Temp"); + QDir dir(dirPath); + + if (!dir.exists()) { + if (!dir.mkpath(".")) { + qWarning() << "[xray] failed to create directory:" << dirPath; + } + } + + debugPath = dir.filePath(QStringLiteral("amnezia-xray-config.json")); #else - const QString debugPath = QStringLiteral("/tmp/amnezia-xray-config.json"); + debugPath = QStringLiteral("/tmp/amnezia-xray-config.json"); #endif + QFile f(debugPath); if (f.open(QIODevice::WriteOnly | QIODevice::Truncate)) { f.write(bytes);