summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@digia.com>2014-03-19 15:20:06 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-20 13:10:49 +0100
commitd7eb3d128037cefeeb75adf4fe3453cf2fe565eb (patch)
treef9b9ecaa49d9f876cb94dbd79741af55f8a738fa
parentd2da291c9345ead24ac5113d6783de471aa210c4 (diff)
Fix creating directory hierarchy for WinRT
mkpath was not working consistently on WinRT. The reason is that createDirectory() starts from C:/ which is outside the sandbox and an illegal access error has been returned. In case the chunk is still inside the "known" writable area, we continue to the next chunk. Known writable is derived from QStandardPaths. All but Temp are children of the DataLocation on WinRT. Task-number: QTBUG-35472 Change-Id: I3b4ab390bd321285da51d02f5eeaf06da4d56298 Reviewed-by: Andrew Knight <andrew.knight@digia.com>
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index dbc6d28846..7741eb4c1e 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -74,6 +74,8 @@
# define SECURITY_WIN32
# include <security.h>
#else // !Q_OS_WINRT
+# include "qstandardpaths.h"
+# include "qthreadstorage.h"
# include <wrl.h>
# include <windows.foundation.h>
# include <windows.storage.h>
@@ -1151,6 +1153,18 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea
bool existed = false;
if (isDirPath(chunk, &existed) && existed)
continue;
+#ifdef Q_OS_WINRT
+ static QThreadStorage<QString> dataLocation;
+ if (!dataLocation.hasLocalData())
+ dataLocation.setLocalData(QDir::toNativeSeparators(QStandardPaths::writableLocation(QStandardPaths::DataLocation)));
+ static QThreadStorage<QString> tempLocation;
+ if (!tempLocation.hasLocalData())
+ tempLocation.setLocalData(QDir::toNativeSeparators(QStandardPaths::writableLocation(QStandardPaths::TempLocation)));
+ // We try to create something outside the sandbox, which is forbidden
+ // However we could still try to pass into the sandbox
+ if (dataLocation.localData().startsWith(chunk) || tempLocation.localData().startsWith(chunk))
+ continue;
+#endif
}
return false;
}