From d7eb3d128037cefeeb75adf4fe3453cf2fe565eb Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 19 Mar 2014 15:20:06 +0100 Subject: 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 --- src/corelib/io/qfilesystemengine_win.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/corelib/io/qfilesystemengine_win.cpp') 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 #else // !Q_OS_WINRT +# include "qstandardpaths.h" +# include "qthreadstorage.h" # include # include # include @@ -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 dataLocation; + if (!dataLocation.hasLocalData()) + dataLocation.setLocalData(QDir::toNativeSeparators(QStandardPaths::writableLocation(QStandardPaths::DataLocation))); + static QThreadStorage 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; } -- cgit v1.2.3