From 4536284f34dc09d2040b1c17b004b397b7ae1d08 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 14 May 2024 12:48:19 +0200 Subject: [PATCH] getUSBMountPath(): check for directory 'dirPathUnderMountPath' under mount path. --- common/src/System.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/common/src/System.cpp b/common/src/System.cpp index 8531e8e..6f20e21 100644 --- a/common/src/System.cpp +++ b/common/src/System.cpp @@ -274,8 +274,7 @@ std::optional System::checkForUSBStick(QString const &dirPathUnderMount * Note, do not return an empty string ("") here because a calling method (which could not be * identified till now) is relying on this! */ -QString System::getUSBMountPath() -{ +QString System::getUSBMountPath(QString const &dirPathUnderMountPath) { #if defined (ARCH_DesktopLinux) // DEBUG / TEST: @@ -316,8 +315,13 @@ QString System::getUSBMountPath() mountLine = line.split(' '); if (mountLine.size() > 3) { - qDebug() << "System::getUSBMountPath(): " << mountLine.at(0) << " is mounted on " << mountLine.at(2); - return mountLine.at(2); + qCritical() << "System::getUSBMountPath(): " << mountLine.at(0) << " is mounted on " << mountLine.at(2); + QDir d(QDir::cleanPath(mountLine.at(2) + QDir::separator() + dirPathUnderMountPath)); + if (d.exists()) { + return mountLine.at(2); + } else { + qCritical() << "directory" << d.absolutePath() << "does not exist"; + } } } }