From 8fe9a8e9cf781c4b9c1df5085d371f72e8b647fb Mon Sep 17 00:00:00 2001
From: Patrick Spendrin <ps_ml@gmx.de>
Date: Mon, 28 Apr 2014 11:08:19 +0200
Subject: [PATCH 15/28] use QFileInfo to also find hidden paths on windows
---
src/file/autotest/fileindexerconfigutils.h | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/file/autotest/fileindexerconfigutils.h b/src/file/autotest/fileindexerconfigutils.h
index ab52f3b..15926c5 100644
--- a/src/file/autotest/fileindexerconfigutils.h
+++ b/src/file/autotest/fileindexerconfigutils.h
@@ -29,6 +29,10 @@
#include <QDir>
#include <QTextStream>
+#ifdef Q_OS_WIN
+#include <windows.h>
+#endif
+
namespace Baloo
{
namespace Test
@@ -52,7 +56,7 @@ KTempDir* createTmpFolders(const QStringList& folders)
// If the temporary directory is in a hidden folder, then the tests will fail,
// so we use /tmp/ instead.
// TODO: Find a better solution
- if (tmpDir->name().contains("/.")) {
+ if (QFileInfo(tmpDir->name()).isHidden()) {
delete tmpDir;
tmpDir = new KTempDir(QLatin1String("/tmp/"));
}
@@ -62,6 +66,13 @@ KTempDir* createTmpFolders(const QStringList& folders)
if (!dir.exists(sf)) {
dir.mkdir(sf);
}
+#ifdef Q_OS_WIN
+ if(sf.startsWith(".")) {
+ if(!SetFileAttributesW(reinterpret_cast<WCHAR*>((dir.path() + "/" + sf).toUtf16()), FILE_ATTRIBUTE_HIDDEN)) {
+ qWarning("failed to set 'hidden' attribute!");
+ }
+ }
+#endif
dir.cd(sf);
}
}
@@ -75,7 +86,7 @@ KTempDir* createTmpFilesAndFolders(const QStringList& list)
// If the temporary directory is in a hidden folder, then the tests will fail,
// so we use /tmp/ instead.
// TODO: Find a better solution
- if (tmpDir->name().contains("/.")) {
+ if (QFileInfo(tmpDir->name()).isHidden()) {
delete tmpDir;
tmpDir = new KTempDir(QLatin1String("/tmp/"));
}
@@ -86,6 +97,13 @@ KTempDir* createTmpFilesAndFolders(const QStringList& list)
if (!dir.exists(sf)) {
dir.mkdir(sf);
}
+#ifdef Q_OS_WIN
+ if(sf.startsWith(".")) {
+ if(!SetFileAttributesW(reinterpret_cast<WCHAR*>((dir.path() + "/" + sf).toUtf16()), FILE_ATTRIBUTE_HIDDEN)) {
+ qWarning("failed to set 'hidden' attribute!");
+ }
+ }
+#endif
dir.cd(sf);
}
}
--
1.9.0