From 812461e08a21823c9527f16c3fadc1daa249bb9c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 24 Apr 2014 15:16:56 +0200 Subject: [PATCH] qtdiag: Dump writable locations of QStandardPaths. Indicate writable locations by asterisks. Task-number: QTBUG-38483 Change-Id: I3e5efbd6db032b4feaee2b5013a9304c6cbfc73d Reviewed-by: Joerg Bornemann --- src/qtdiag/qtdiag.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/qtdiag/qtdiag.cpp b/src/qtdiag/qtdiag.cpp index 4f9eed8..acf4bce 100644 --- a/src/qtdiag/qtdiag.cpp +++ b/src/qtdiag/qtdiag.cpp @@ -183,10 +183,29 @@ static QStringList toNativeSeparators(QStringList in) if (platformIntegration->hasCapability(QPlatformIntegration::capability)) \ str << ' ' << #capability; +// Dump values of QStandardPaths, indicate writable locations by asterisk. +static void dumpStandardLocation(QTextStream &str, QStandardPaths::StandardLocation location) +{ + str << '"' << QStandardPaths::displayName(location) << '"'; + const QStringList directories = QStandardPaths::standardLocations(location); + const QString writableDirectory = QStandardPaths::writableLocation(location); + const int writableIndex = directories.indexOf(writableDirectory); + for (int i = 0; i < directories.size(); ++i) { + str << ' '; + if (i == writableIndex) + str << '*'; + str << QDir::toNativeSeparators(directories.at(i)); + if (i == writableIndex) + str << '*'; + } + if (!writableDirectory.isEmpty() && writableIndex < 0) + str << " *" << QDir::toNativeSeparators(writableDirectory) << '*'; +} + #define DUMP_STANDARDPATH(str, location) \ - str << " " << #location << ": \"" \ - << QStandardPaths::displayName(QStandardPaths::location) << '"' \ - << ' ' << toNativeSeparators(QStandardPaths::standardLocations(QStandardPaths::location)) << '\n'; + str << " " << #location << ": "; \ + dumpStandardLocation(str, QStandardPaths::location); \ + str << '\n'; #define DUMP_LIBRARYPATH(str, loc) \ str << " " << #loc << ": " << QDir::toNativeSeparators(QLibraryInfo::location(QLibraryInfo::loc)) << '\n'; -- 2.7.4