From 45b0f1be686cfba8dcecb9be5c875cae59c69276 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 5 Jun 2020 09:24:37 +0200 Subject: Remove winrt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Macros and the await helper function from qfunctions_winrt(_p).h are needed in other Qt modules which use UWP APIs on desktop windows. Task-number: QTBUG-84434 Change-Id: Ice09c11436ad151c17bdccd2c7defadd08c13925 Reviewed-by: Tor Arne Vestbø --- src/corelib/io/io.pri | 46 +- src/corelib/io/qdir.cpp | 15 +- src/corelib/io/qfileinfo.cpp | 2 +- src/corelib/io/qfileselector.cpp | 3 - src/corelib/io/qfilesystemengine_win.cpp | 185 +------- src/corelib/io/qfilesystementry.cpp | 14 - src/corelib/io/qfilesystemmetadata_p.h | 4 - src/corelib/io/qfilesystemwatcher.cpp | 8 +- src/corelib/io/qfilesystemwatcher_p.h | 4 +- src/corelib/io/qfilesystemwatcher_win.cpp | 10 - src/corelib/io/qfilesystemwatcher_win_p.h | 2 - src/corelib/io/qfsfileengine_win.cpp | 59 +-- src/corelib/io/qlockfile_win.cpp | 21 - src/corelib/io/qprocess.cpp | 3 +- src/corelib/io/qsettings.cpp | 63 +-- src/corelib/io/qsettings_p.h | 4 - src/corelib/io/qsettings_winrt.cpp | 690 ------------------------------ src/corelib/io/qstandardpaths_winrt.cpp | 138 ------ src/corelib/io/qstorageinfo_p.h | 2 +- src/corelib/io/qstorageinfo_stub.cpp | 67 --- src/corelib/io/qtemporaryfile.cpp | 9 +- 21 files changed, 46 insertions(+), 1303 deletions(-) delete mode 100644 src/corelib/io/qsettings_winrt.cpp delete mode 100644 src/corelib/io/qstandardpaths_winrt.cpp delete mode 100644 src/corelib/io/qstorageinfo_stub.cpp (limited to 'src/corelib/io') diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 97b7f3970c..c062d9948b 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -111,7 +111,7 @@ qtConfig(processenvironment) { io/qprocess.h \ io/qprocess_p.h - win32:!winrt: \ + win32: \ SOURCES += io/qprocess_win.cpp else: unix: \ SOURCES += io/qprocess_unix.cpp @@ -125,11 +125,7 @@ qtConfig(settings) { io/qsettings_p.h win32 { - !winrt { - SOURCES += io/qsettings_win.cpp - } else { - SOURCES += io/qsettings_winrt.cpp - } + SOURCES += io/qsettings_win.cpp } else: darwin:!nacl { SOURCES += io/qsettings_mac.cpp } @@ -137,32 +133,26 @@ qtConfig(settings) { } win32 { - SOURCES += io/qfsfileengine_win.cpp - SOURCES += io/qlockfile_win.cpp - SOURCES += io/qfilesystemengine_win.cpp + SOURCES += io/qfsfileengine_win.cpp + SOURCES += io/qlockfile_win.cpp + SOURCES += io/qfilesystemengine_win.cpp - qtConfig(filesystemiterator) { - SOURCES += io/qfilesystemiterator_win.cpp - } + qtConfig(filesystemiterator) { + SOURCES += io/qfilesystemiterator_win.cpp + } - !winrt { - HEADERS += \ - io/qwindowspipereader_p.h \ - io/qwindowspipewriter_p.h + HEADERS += \ + io/qwindowspipereader_p.h \ + io/qwindowspipewriter_p.h - SOURCES += \ - io/qstandardpaths_win.cpp \ - io/qstorageinfo_win.cpp \ - io/qwindowspipereader.cpp \ - io/qwindowspipewriter.cpp + SOURCES += \ + io/qstandardpaths_win.cpp \ + io/qstorageinfo_win.cpp \ + io/qwindowspipereader.cpp \ + io/qwindowspipewriter.cpp - LIBS += -lmpr -luserenv - QMAKE_USE_PRIVATE += netapi32 - } else { - SOURCES += \ - io/qstandardpaths_winrt.cpp \ - io/qstorageinfo_stub.cpp - } + LIBS += -lmpr -luserenv + QMAKE_USE_PRIVATE += netapi32 } else:unix { SOURCES += \ io/qfsfileengine_unix.cpp \ diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 368ad648e0..647f6746a5 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -83,7 +83,7 @@ static QString driveSpec(const QString &path) #endif enum { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) OSSupportsUncPaths = true #else OSSupportsUncPaths = false @@ -100,11 +100,6 @@ static int rootLength(const QString &name, bool allowUncPaths) const int nextSlash = name.indexOf(QLatin1Char('/'), 2); return nextSlash >= 0 ? nextSlash + 1 : len; } -#if defined(Q_OS_WINRT) - const QString rootPath = QDir::rootPath(); // rootPath contains the trailing slash - if (name.startsWith(rootPath, Qt::CaseInsensitive)) - return rootPath.size(); -#endif // Q_OS_WINRT #if defined(Q_OS_WIN) if (len >= 2 && name.at(1) == QLatin1Char(':')) { // Handle a possible drive letter @@ -196,11 +191,7 @@ inline void QDirPrivate::setPath(const QString &path) if (p.endsWith(QLatin1Char('/')) && p.length() > 1 #if defined(Q_OS_WIN) -# if defined (Q_OS_WINRT) - && (!(p.toLower() == QDir::rootPath().toLower())) -# else && (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter())) -# endif #endif ) { p.truncate(p.length() - 1); @@ -2373,11 +2364,7 @@ static QString qt_cleanPath(const QString &path, bool *ok) // Strip away last slash except for root directories if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) { #if defined (Q_OS_WIN) -# if defined(Q_OS_WINRT) - if (!((ret.length() == 3 || ret.length() == QDir::rootPath().length()) && ret.at(1) == QLatin1Char(':'))) -# else if (!(ret.length() == 3 && ret.at(1) == QLatin1Char(':'))) -# endif #endif ret.chop(1); } diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 824215d1d9..f33f03262f 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -1178,7 +1178,7 @@ bool QFileInfo::isRoot() const return false; if (d->fileEngine == nullptr) { if (d->fileEntry.isRoot()) { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) //the path is a drive root, but the drive may not exist //for backward compatibility, return true only if the drive exists if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute)) diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp index 0c42a98b37..1a58da1e18 100644 --- a/src/corelib/io/qfileselector.cpp +++ b/src/corelib/io/qfileselector.cpp @@ -346,9 +346,6 @@ QStringList QFileSelectorPrivate::platformSelectors() #if defined(Q_OS_WIN) ret << QStringLiteral("windows"); ret << QSysInfo::kernelType(); // "winnt" -# if defined(Q_OS_WINRT) - ret << QStringLiteral("winrt"); -# endif #elif defined(Q_OS_UNIX) ret << QStringLiteral("unix"); # if !defined(Q_OS_ANDROID) && !defined(Q_OS_QNX) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index a4f47cbf24..4c1b9f87c2 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -61,33 +61,16 @@ #include #include #include -#ifndef Q_OS_WINRT -# include -# include -# include -# include -# include -#endif +#include +#include +#include +#include +#include #include #include #include -#ifndef Q_OS_WINRT -# define SECURITY_WIN32 -# include -#else // !Q_OS_WINRT -# include "qstandardpaths.h" -# include "qthreadstorage.h" -# include -# include -# include -# include - -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Storage; -using namespace ABI::Windows::ApplicationModel; -#endif // Q_OS_WINRT +#define SECURITY_WIN32 +#include #ifndef SPI_GETPLATFORMTYPE #define SPI_GETPLATFORMTYPE 257 @@ -153,11 +136,11 @@ typedef struct _REPARSE_DATA_BUFFER { # define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) #endif -#if defined(Q_OS_WINRT) || defined(QT_BOOTSTRAPPED) +#if defined(QT_BOOTSTRAPPED) # define QT_FEATURE_fslibs -1 #else # define QT_FEATURE_fslibs 1 -#endif // Q_OS_WINRT +#endif // QT_BOOTSTRAPPED #if QT_CONFIG(fslibs) #include @@ -291,7 +274,6 @@ static inline bool toFileTime(const QDateTime &date, FILETIME *fileTime) static QString readSymLink(const QFileSystemEntry &link) { QString result; -#if !defined(Q_OS_WINRT) HANDLE handle = CreateFile((wchar_t*)link.nativeFilePath().utf16(), FILE_READ_EA, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, @@ -346,9 +328,6 @@ static QString readSymLink(const QFileSystemEntry &link) } #endif // QT_CONFIG(fslibs) } -#else - Q_UNUSED(link); -#endif // Q_OS_WINRT return result; } @@ -416,11 +395,7 @@ static inline bool getFindData(QString path, WIN32_FIND_DATA &findData) // can't handle drives if (!path.endsWith(QLatin1Char(':'))) { -#ifndef Q_OS_WINRT HANDLE hFind = ::FindFirstFile((wchar_t*)path.utf16(), &findData); -#else - HANDLE hFind = ::FindFirstFileEx((const wchar_t*)path.utf16(), FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0); -#endif if (hFind != INVALID_HANDLE_VALUE) { ::FindClose(hFind); return true; @@ -531,7 +506,6 @@ private: bool QFileSystemEngine::uncListSharesOnServer(const QString &server, QStringList *list) { DWORD res = ERROR_NOT_SUPPORTED; -#ifndef Q_OS_WINRT SHARE_INFO_1 *BufPtr, *p; DWORD er = 0, tr = 0, resume = 0, i; do { @@ -546,10 +520,6 @@ bool QFileSystemEngine::uncListSharesOnServer(const QString &server, QStringList } NetApiBufferFree(BufPtr); } while (res == ERROR_MORE_DATA); -#else - Q_UNUSED(server); - Q_UNUSED(list); -#endif return res == ERROR_SUCCESS; } @@ -615,16 +585,6 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path) } if (retLen != 0) absPath = QString::fromWCharArray(buf.data(), retLen); -# if defined(Q_OS_WINRT) - // Win32 returns eg C:/ as root directory with a trailing /. - // WinRT returns the sandbox root without /. - // Also C:/../.. returns C:/ on Win32, while for WinRT it steps outside the package - // and goes beyond package root. Hence force the engine to stay inside - // the package. - const QString rootPath = QDir::toNativeSeparators(QDir::rootPath()); - if (absPath.size() < rootPath.size() && rootPath.startsWith(absPath)) - absPath = rootPath; -# endif // Q_OS_WINRT // This is really ugly, but GetFullPathName strips off whitespace at the end. // If you for instance write ". " in the lineedit of QFileDialog, @@ -652,7 +612,6 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath()); } -#ifndef Q_OS_WINRT // The path should be absolute at this point. // From the docs : // Absolute paths begin with the directory separator "/" @@ -665,7 +624,6 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) // Force uppercase drive letters. ret[0] = ret.at(0).toUpper(); } -#endif // !Q_OS_WINRT return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath()); } @@ -681,7 +639,6 @@ typedef struct _FILE_ID_INFO { // File ID for Windows up to version 7 and FAT32 drives static inline QByteArray fileId(HANDLE handle) { -#ifndef Q_OS_WINRT BY_HANDLE_FILE_INFORMATION info; if (GetFileInformationByHandle(handle, &info)) { char buffer[sizeof "01234567:0123456701234567"]; @@ -691,10 +648,6 @@ static inline QByteArray fileId(HANDLE handle) info.nFileIndexLow); return buffer; } -#else // !Q_OS_WINRT - Q_UNUSED(handle); - Q_UNIMPLEMENTED(); -#endif // Q_OS_WINRT return QByteArray(); } @@ -727,23 +680,10 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry) QByteArray result; -#ifndef Q_OS_WINRT const HANDLE handle = CreateFile((wchar_t*)entry.nativeFilePath().utf16(), 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); -#else // !Q_OS_WINRT - CREATEFILE2_EXTENDED_PARAMETERS params; - params.dwSize = sizeof(params); - params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; - params.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS; - params.dwSecurityQosFlags = SECURITY_ANONYMOUS; - params.lpSecurityAttributes = NULL; - params.hTemplateFile = NULL; - const HANDLE handle = - CreateFile2((const wchar_t*)entry.nativeFilePath().utf16(), 0, - FILE_SHARE_READ, OPEN_EXISTING, ¶ms); -#endif // Q_OS_WINRT if (handle != INVALID_HANDLE_VALUE) { result = id(handle); CloseHandle(handle); @@ -994,7 +934,6 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa { bool entryExists = false; DWORD fileAttrib = 0; -#if !defined(Q_OS_WINRT) if (fname.isDriveRoot()) { // a valid drive ?? const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); @@ -1006,7 +945,6 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa entryExists = true; } } else { -#endif const QString &path = fname.nativeFilePath(); bool is_dir = false; if (path.startsWith(QLatin1String("\\\\?\\UNC"))) { @@ -1037,9 +975,7 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa fileAttrib = FILE_ATTRIBUTE_DIRECTORY; entryExists = true; } -#if !defined(Q_OS_WINRT) } -#endif if (entryExists) data.fillFromFileAttribute(fileAttrib); return entryExists; @@ -1078,34 +1014,12 @@ bool QFileSystemEngine::fillMetaData(HANDLE fHandle, QFileSystemMetaData &data, { data.entryFlags &= ~what; clearWinStatData(data); -#ifndef Q_OS_WINRT BY_HANDLE_FILE_INFORMATION fileInfo; UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); if (GetFileInformationByHandle(fHandle , &fileInfo)) { data.fillFromFindInfo(fileInfo); } SetErrorMode(oldmode); -#else // !Q_OS_WINRT - FILE_BASIC_INFO fileBasicInfo; - if (GetFileInformationByHandleEx(fHandle, FileBasicInfo, &fileBasicInfo, sizeof(fileBasicInfo))) { - data.fillFromFileAttribute(fileBasicInfo.FileAttributes); - data.birthTime_.dwHighDateTime = fileBasicInfo.CreationTime.HighPart; - data.birthTime_.dwLowDateTime = fileBasicInfo.CreationTime.LowPart; - data.changeTime_.dwHighDateTime = fileBasicInfo.ChangeTime.HighPart; - data.changeTime_.dwLowDateTime = fileBasicInfo.ChangeTime.LowPart; - data.lastAccessTime_.dwHighDateTime = fileBasicInfo.LastAccessTime.HighPart; - data.lastAccessTime_.dwLowDateTime = fileBasicInfo.LastAccessTime.LowPart; - data.lastWriteTime_.dwHighDateTime = fileBasicInfo.LastWriteTime.HighPart; - data.lastWriteTime_.dwLowDateTime = fileBasicInfo.LastWriteTime.LowPart; - if (!(data.fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY)) { - FILE_STANDARD_INFO fileStandardInfo; - if (GetFileInformationByHandleEx(fHandle, FileStandardInfo, &fileStandardInfo, sizeof(fileStandardInfo))) - data.size_ = fileStandardInfo.EndOfFile.QuadPart; - } else - data.size_ = 0; - data.knownFlagsMask |= QFileSystemMetaData::Times | QFileSystemMetaData::SizeAttribute; - } -#endif // Q_OS_WINRT return data.hasFlags(what); } @@ -1138,9 +1052,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM } if (what & QFileSystemMetaData::WinStatFlags) { -#ifndef Q_OS_WINRT UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); -#endif clearWinStatData(data); WIN32_FIND_DATA findData; // The memory structure for WIN32_FIND_DATA is same as WIN32_FILE_ATTRIBUTE_DATA @@ -1153,15 +1065,11 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM } else { if (!tryFindFallback(fname, data)) if (!tryDriveUNCFallback(fname, data)) { -#ifndef Q_OS_WINRT SetErrorMode(oldmode); -#endif return false; } } -#ifndef Q_OS_WINRT SetErrorMode(oldmode); -#endif } if (what & QFileSystemMetaData::Permissions) @@ -1201,16 +1109,7 @@ static bool isDirPath(const QString &dirPath, bool *existed) path += QLatin1Char('\\'); const QString longPath = QFSFileEnginePrivate::longFileName(path); -#ifndef Q_OS_WINRT DWORD fileAttrib = ::GetFileAttributes(reinterpret_cast(longPath.utf16())); -#else // Q_OS_WINRT - DWORD fileAttrib = INVALID_FILE_ATTRIBUTES; - WIN32_FILE_ATTRIBUTE_DATA data; - if (::GetFileAttributesEx(reinterpret_cast(longPath.utf16()), - GetFileExInfoStandard, &data)) { - fileAttrib = data.dwFileAttributes; - } -#endif // Q_OS_WINRT if (fileAttrib == INVALID_FILE_ATTRIBUTES) { int errorCode = GetLastError(); if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { @@ -1314,36 +1213,10 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo //static QString QFileSystemEngine::rootPath() { -#if defined(Q_OS_WINRT) - // We specify the package root as root directory - QString ret = QLatin1String("/"); - // Get package location - ComPtr statics; - if (FAILED(GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_Package).Get(), &statics))) - return ret; - ComPtr package; - if (FAILED(statics->get_Current(&package))) - return ret; - ComPtr installedLocation; - if (FAILED(package->get_InstalledLocation(&installedLocation))) - return ret; - - ComPtr item; - if (FAILED(installedLocation.As(&item))) - return ret; - - HString finalWinPath; - if (FAILED(item->get_Path(finalWinPath.GetAddressOf()))) - return ret; - - const QString qtWinPath = QDir::fromNativeSeparators(QString::fromWCharArray(finalWinPath.GetRawBuffer(nullptr))); - ret = qtWinPath.endsWith(QLatin1Char('/')) ? qtWinPath : qtWinPath + QLatin1Char('/'); -#else QString ret = QString::fromLatin1(qgetenv("SystemDrive")); if (ret.isEmpty()) ret = QLatin1String("c:"); ret.append(QLatin1Char('/')); -#endif return ret; } @@ -1391,7 +1264,6 @@ QString QFileSystemEngine::homePath() QString QFileSystemEngine::tempPath() { QString ret; -#ifndef Q_OS_WINRT wchar_t tempPath[MAX_PATH]; const DWORD len = GetTempPath(MAX_PATH, tempPath); if (len) { // GetTempPath() can return short names, expand. @@ -1406,24 +1278,6 @@ QString QFileSystemEngine::tempPath() ret.chop(1); ret = QDir::fromNativeSeparators(ret); } -#else // !Q_OS_WINRT - ComPtr applicationDataStatics; - if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_ApplicationData).Get(), &applicationDataStatics))) - return ret; - ComPtr applicationData; - if (FAILED(applicationDataStatics->get_Current(&applicationData))) - return ret; - ComPtr tempFolder; - if (FAILED(applicationData->get_TemporaryFolder(&tempFolder))) - return ret; - ComPtr tempFolderItem; - if (FAILED(tempFolder.As(&tempFolderItem))) - return ret; - HString path; - if (FAILED(tempFolderItem->get_Path(path.GetAddressOf()))) - return ret; - ret = QDir::fromNativeSeparators(QString::fromWCharArray(path.GetRawBuffer(nullptr))); -#endif // Q_OS_WINRT if (ret.isEmpty()) { ret = QLatin1String("C:/tmp"); } else if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) @@ -1478,17 +1332,8 @@ bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSy //static bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) { -#ifndef Q_OS_WINRT bool ret = ::CopyFile((wchar_t*)source.nativeFilePath().utf16(), (wchar_t*)target.nativeFilePath().utf16(), true) != 0; -#else // !Q_OS_WINRT - COPYFILE2_EXTENDED_PARAMETERS copyParams = { - sizeof(copyParams), COPY_FILE_FAIL_IF_EXISTS, NULL, NULL, NULL - }; - HRESULT hres = ::CopyFile2((const wchar_t*)source.nativeFilePath().utf16(), - (const wchar_t*)target.nativeFilePath().utf16(), ©Params); - bool ret = SUCCEEDED(hres); -#endif // Q_OS_WINRT if(!ret) error = QSystemError(::GetLastError(), QSystemError::NativeError); return ret; @@ -1500,13 +1345,8 @@ bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSy Q_CHECK_FILE_NAME(source, false); Q_CHECK_FILE_NAME(target, false); -#ifndef Q_OS_WINRT bool ret = ::MoveFile((wchar_t*)source.nativeFilePath().utf16(), (wchar_t*)target.nativeFilePath().utf16()) != 0; -#else // !Q_OS_WINRT - bool ret = ::MoveFileEx((const wchar_t*)source.nativeFilePath().utf16(), - (const wchar_t*)target.nativeFilePath().utf16(), 0) != 0; -#endif // Q_OS_WINRT if(!ret) error = QSystemError(::GetLastError(), QSystemError::NativeError); return ret; @@ -1547,7 +1387,6 @@ bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError & bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, QFileSystemEntry &newLocation, QSystemError &error) { -#ifndef Q_OS_WINRT // we need the "display name" of the file, so can't use nativeAbsoluteFilePath const QString sourcePath = QDir::toNativeSeparators(absoluteName(source).filePath()); @@ -1626,12 +1465,6 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, } return true; -#else // Q_OS_WINRT - Q_UNUSED(source); - Q_UNUSED(newLocation); - Q_UNUSED(error); - return false; -#endif } //static diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 3ff90bd0a3..3c8a85291a 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -166,16 +166,6 @@ void QFileSystemEntry::resolveNativeFilePath() const m_nativeFilePath = QDir::toNativeSeparators(m_filePath); #else m_nativeFilePath = QFile::encodeName(QDir::toNativeSeparators(m_filePath)); -#endif -#ifdef Q_OS_WINRT - while (m_nativeFilePath.startsWith(QLatin1Char('\\'))) - m_nativeFilePath.remove(0,1); - if (m_nativeFilePath.isEmpty()) - m_nativeFilePath.append(QLatin1Char('.')); - // WinRT/MSVC2015 allows a maximum of 256 characters for a filepath - // unless //?/ is prepended which extends the rule to have a maximum - // of 256 characters in the filename plus the preprending path - m_nativeFilePath.prepend("\\\\?\\"); #endif } } @@ -302,13 +292,9 @@ bool QFileSystemEntry::isDriveRoot() const bool QFileSystemEntry::isDriveRootPath(const QString &path) { -#ifndef Q_OS_WINRT return (path.length() == 3 && path.at(0).isLetter() && path.at(1) == QLatin1Char(':') && path.at(2) == QLatin1Char('/')); -#else // !Q_OS_WINRT - return path == QDir::rootPath(); -#endif // !Q_OS_WINRT } #endif // Q_OS_WIN diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 3154658e5c..dbd89f5903 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -235,9 +235,7 @@ public: #if defined(Q_OS_WIN) inline void fillFromFileAttribute(DWORD fileAttribute, bool isDriveRoot = false); inline void fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType = false, bool isDriveRoot = false); -# ifndef Q_OS_WINRT inline void fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fileInfo); -# endif #endif private: friend class QFileSystemEngine; @@ -372,7 +370,6 @@ inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, boo } } -#ifndef Q_OS_WINRT inline void QFileSystemMetaData::fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fileInfo) { fillFromFileAttribute(fileInfo.dwFileAttributes); @@ -388,7 +385,6 @@ inline void QFileSystemMetaData::fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fi } knownFlagsMask |= Times | SizeAttribute; } -#endif // !Q_OS_WINRT #endif // Q_OS_WIN QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index 96d9210c1c..a5e83ac11f 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -105,7 +105,7 @@ void QFileSystemWatcherPrivate::init() SIGNAL(directoryChanged(QString,bool)), q, SLOT(_q_directoryChanged(QString,bool))); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) QObject::connect(static_cast(native), &QWindowsFileSystemWatcherEngine::driveLockForRemoval, q, [this] (const QString &p) { _q_winDriveLockForRemoval(p); }); @@ -115,7 +115,7 @@ void QFileSystemWatcherPrivate::init() QObject::connect(static_cast(native), &QWindowsFileSystemWatcherEngine::driveRemoved, q, [this] (const QString &p) { _q_winDriveRemoved(p); }); -#endif // !Q_OS_WINRT +#endif // Q_OS_WIN } } @@ -162,7 +162,7 @@ void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool re emit q->directoryChanged(path, QFileSystemWatcher::QPrivateSignal()); } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) void QFileSystemWatcherPrivate::_q_winDriveLockForRemoval(const QString &path) { @@ -201,7 +201,7 @@ void QFileSystemWatcherPrivate::_q_winDriveRemoved(const QString &path) if (!path.isEmpty()) temporarilyRemovedPaths.remove(path.at(0)); } -#endif // Q_OS_WIN && !Q_OS_WINRT +#endif // Q_OS_WIN /*! \class QFileSystemWatcher diff --git a/src/corelib/io/qfilesystemwatcher_p.h b/src/corelib/io/qfilesystemwatcher_p.h index 1997ff6c86..cecfe03ff5 100644 --- a/src/corelib/io/qfilesystemwatcher_p.h +++ b/src/corelib/io/qfilesystemwatcher_p.h @@ -108,14 +108,14 @@ public: void _q_fileChanged(const QString &path, bool removed); void _q_directoryChanged(const QString &path, bool removed); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) void _q_winDriveLockForRemoval(const QString &); void _q_winDriveLockForRemovalFailed(const QString &); void _q_winDriveRemoved(const QString &); private: QHash temporarilyRemovedPaths; -#endif // Q_OS_WIN && !Q_OS_WINRT +#endif // Q_OS_WIN }; diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index 2f0a209b76..cc04288de5 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -52,7 +52,6 @@ #include -#ifndef Q_OS_WINRT # include # include # include @@ -61,7 +60,6 @@ # include # include # include -#endif // !Q_OS_WINRT QT_BEGIN_NAMESPACE @@ -85,7 +83,6 @@ static Qt::HANDLE createChangeNotification(const QString &path, uint flags) return result; } -#ifndef Q_OS_WINRT /////////// // QWindowsRemovableDriveListener // Listen for the various WM_DEVICECHANGE message indicating drive addition/removal @@ -330,7 +327,6 @@ void QWindowsRemovableDriveListener::addPath(const QString &p) m_removableDrives.push_back(re); } -#endif // !Q_OS_WINRT /////////// // QWindowsFileSystemWatcherEngine @@ -343,7 +339,6 @@ QWindowsFileSystemWatcherEngine::Handle::Handle() QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine(QObject *parent) : QFileSystemWatcherEngine(parent) { -#ifndef Q_OS_WINRT if (QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance()) { m_driveListener = new QWindowsRemovableDriveListener(this); eventDispatcher->installNativeEventFilter(m_driveListener); @@ -360,7 +355,6 @@ QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine(QObject *parent qWarning("QFileSystemWatcher: Removable drive notification will not work" " if there is no QCoreApplication instance."); } -#endif // !Q_OS_WINRT } QWindowsFileSystemWatcherEngine::~QWindowsFileSystemWatcherEngine() @@ -524,14 +518,12 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, } } -#ifndef Q_OS_WINRT if (Q_LIKELY(m_driveListener)) { for (const QString &path : paths) { if (!unhandled.contains(path)) m_driveListener->addPath(path); } } -#endif // !Q_OS_WINRT return unhandled; } @@ -763,6 +755,4 @@ void QWindowsFileSystemWatcherEngineThread::wakeup() QT_END_NAMESPACE -#ifndef Q_OS_WINRT # include "qfilesystemwatcher_win.moc" -#endif diff --git a/src/corelib/io/qfilesystemwatcher_win_p.h b/src/corelib/io/qfilesystemwatcher_win_p.h index 9d74ca3f61..138b6badf2 100644 --- a/src/corelib/io/qfilesystemwatcher_win_p.h +++ b/src/corelib/io/qfilesystemwatcher_win_p.h @@ -126,9 +126,7 @@ signals: private: QList threads; -#ifndef Q_OS_WINRT QWindowsRemovableDriveListener *m_driveListener = nullptr; -#endif }; class QFileSystemWatcherPathKey : public QString diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index dd4882a2bc..6b1ab5739e 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -53,18 +53,14 @@ #include #include #include -#ifndef Q_OS_WINRT -# include -# include -#endif +#include +#include #include #include #include #include -#ifndef Q_OS_WINRT -# define SECURITY_WIN32 -# include -#endif +#define SECURITY_WIN32 +#include #ifndef PATH_MAX #define PATH_MAX FILENAME_MAX @@ -88,16 +84,12 @@ QString QFSFileEnginePrivate::longFileName(const QString &path) return path; QString absPath = QFileSystemEngine::nativeAbsoluteFilePath(path); -#if !defined(Q_OS_WINRT) QString prefix = QLatin1String("\\\\?\\"); if (isUncPath(absPath)) { prefix.append(QLatin1String("UNC\\")); // "\\\\?\\UNC\\" absPath.remove(0, 2); } return prefix + absPath; -#else - return absPath; -#endif } /* @@ -123,7 +115,6 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) ? OPEN_ALWAYS : OPEN_EXISTING; // Create the file handle. -#ifndef Q_OS_WINRT SECURITY_ATTRIBUTES securityAtts = { sizeof(SECURITY_ATTRIBUTES), NULL, FALSE }; fileHandle = CreateFile((const wchar_t*)fileEntry.nativeFilePath().utf16(), accessRights, @@ -132,13 +123,6 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) creationDisp, FILE_ATTRIBUTE_NORMAL, NULL); -#else // !Q_OS_WINRT - fileHandle = CreateFile2((const wchar_t*)fileEntry.nativeFilePath().utf16(), - accessRights, - shareMode, - creationDisp, - NULL); -#endif // Q_OS_WINRT // Bail out on error. if (fileHandle == INVALID_HANDLE_VALUE) { @@ -428,7 +412,6 @@ int QFSFileEnginePrivate::nativeHandle() const */ bool QFSFileEnginePrivate::nativeIsSequential() const { -#if !defined(Q_OS_WINRT) HANDLE handle = fileHandle; if (fh || fd != -1) handle = (HANDLE)_get_osfhandle(fh ? QT_FILENO(fh) : fd); @@ -438,9 +421,6 @@ bool QFSFileEnginePrivate::nativeIsSequential() const DWORD fileType = GetFileType(handle); return (fileType == FILE_TYPE_CHAR) || (fileType == FILE_TYPE_PIPE); -#else - return false; -#endif } bool QFSFileEngine::caseSensitive() const @@ -450,7 +430,6 @@ bool QFSFileEngine::caseSensitive() const QString QFSFileEngine::currentPath(const QString &fileName) { -#if !defined(Q_OS_WINRT) QString ret; //if filename is a drive: then get the pwd of that drive if (fileName.length() >= 2 && @@ -469,13 +448,8 @@ QString QFSFileEngine::currentPath(const QString &fileName) if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters. return ret; -#else // !Q_OS_WINRT - Q_UNUSED(fileName); - return QFileSystemEngine::currentPath().filePath(); -#endif // Q_OS_WINRT } -#if !defined(Q_OS_WINRT) // cf QStorageInfo::isReady static inline bool isDriveReady(const wchar_t *path) { @@ -485,12 +459,10 @@ static inline bool isDriveReady(const wchar_t *path) || GetVolumeInformation(path, nullptr, 0, nullptr, nullptr, &fileSystemFlags, nullptr, 0) == TRUE; } -#endif // !Q_OS_WINRT QFileInfoList QFSFileEngine::drives() { QFileInfoList ret; -#if !defined(Q_OS_WINRT) const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); quint32 driveBits = (quint32) GetLogicalDrives() & 0x3ffffff; wchar_t driveName[] = L"A:\\"; @@ -503,10 +475,6 @@ QFileInfoList QFSFileEngine::drives() } ::SetErrorMode(oldErrorMode); return ret; -#else // !Q_OS_WINRT - ret.append(QFileInfo(QLatin1String("/"))); - return ret; -#endif // Q_OS_WINRT } bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) const @@ -529,7 +497,6 @@ bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) cons bool QFSFileEngine::link(const QString &newName) { -#if !defined(Q_OS_WINRT) bool ret = false; QString linkName = newName; @@ -574,11 +541,6 @@ bool QFSFileEngine::link(const QString &newName) CoUninitialize(); return ret; -#else // !Q_OS_WINRT - Q_UNUSED(newName); - Q_UNIMPLEMENTED(); - return false; -#endif // Q_OS_WINRT } /*! @@ -891,11 +853,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, // first create the file mapping handle DWORD protection = (openMode & QIODevice::WriteOnly) ? PAGE_READWRITE : PAGE_READONLY; -#ifndef Q_OS_WINRT mapHandle = ::CreateFileMapping(handle, 0, protection, 0, 0, 0); -#else - mapHandle = ::CreateFileMappingFromApp(handle, 0, protection, 0, 0); -#endif if (mapHandle == NULL) { q->setError(QFile::PermissionsError, qt_error_string()); #ifdef Q_USE_DEPRECATED_MAP_API @@ -908,24 +866,15 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, DWORD offsetHi = offset >> 32; DWORD offsetLo = offset & Q_UINT64_C(0xffffffff); SYSTEM_INFO sysinfo; -#ifndef Q_OS_WINRT ::GetSystemInfo(&sysinfo); -#else - ::GetNativeSystemInfo(&sysinfo); -#endif DWORD mask = sysinfo.dwAllocationGranularity - 1; DWORD extra = offset & mask; if (extra) offsetLo &= ~mask; // attempt to create the map -#ifndef Q_OS_WINRT LPVOID mapAddress = ::MapViewOfFile(mapHandle, access, offsetHi, offsetLo, size + extra); -#else - LPVOID mapAddress = ::MapViewOfFileFromApp(mapHandle, access, - (ULONG64(offsetHi) << 32) + offsetLo, size + extra); -#endif if (mapAddress) { uchar *address = extra + static_cast(mapAddress); maps[address] = extra; diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp index 277f8d4230..77cdf66694 100644 --- a/src/corelib/io/qlockfile_win.cpp +++ b/src/corelib/io/qlockfile_win.cpp @@ -65,7 +65,6 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() // but Windows doesn't allow recreating it while this handle is open anyway, // so this would only create confusion (can't lock, but no lock file to read from). const DWORD dwShareMode = FILE_SHARE_READ; -#ifndef Q_OS_WINRT SECURITY_ATTRIBUTES securityAtts = { sizeof(SECURITY_ATTRIBUTES), NULL, FALSE }; HANDLE fh = CreateFile((const wchar_t*)fileEntry.nativeFilePath().utf16(), GENERIC_READ | GENERIC_WRITE, @@ -74,13 +73,6 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() CREATE_NEW, // error if already exists FILE_ATTRIBUTE_NORMAL, NULL); -#else // !Q_OS_WINRT - HANDLE fh = CreateFile2((const wchar_t*)fileEntry.nativeFilePath().utf16(), - GENERIC_READ | GENERIC_WRITE, - dwShareMode, - CREATE_NEW, // error if already exists - NULL); -#endif // Q_OS_WINRT if (fh == INVALID_HANDLE_VALUE) { const DWORD lastError = GetLastError(); switch (lastError) { @@ -118,9 +110,6 @@ bool QLockFilePrivate::removeStaleLock() bool QLockFilePrivate::isProcessRunning(qint64 pid, const QString &appname) { - // On WinRT there seems to be no way of obtaining information about other - // processes due to sandboxing -#ifndef Q_OS_WINRT HANDLE procHandle = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); if (!procHandle) return false; @@ -137,17 +126,11 @@ bool QLockFilePrivate::isProcessRunning(qint64 pid, const QString &appname) if (!processName.isEmpty() && processName != appname) return false; // PID got reused by a different application. -#else // !Q_OS_WINRT - Q_UNUSED(pid); - Q_UNUSED(appname); -#endif // Q_OS_WINRT - return true; } QString QLockFilePrivate::processNameByPid(qint64 pid) { -#if !defined(Q_OS_WINRT) typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD); HMODULE hPsapi = LoadLibraryA("psapi"); @@ -179,10 +162,6 @@ QString QLockFilePrivate::processNameByPid(qint64 pid) if (i >= 0) name.truncate(i); return name; -#else - Q_UNUSED(pid); - return QString(); -#endif } void QLockFile::unlock() diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 854752069e..633777fd5c 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -489,8 +489,7 @@ void QProcessPrivate::Channel::clear() You can also call error() to find the type of error that occurred last, and state() to find the current process state. - \note QProcess is not supported on VxWorks, iOS, tvOS, watchOS, - or the Universal Windows Platform. + \note QProcess is not supported on VxWorks, iOS, tvOS, or watchOS. \section1 Communicating via Channels diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index a15dbb772f..5d84713a67 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -78,19 +78,7 @@ #ifdef Q_OS_WIN // for homedirpath reading from registry # include -# ifndef Q_OS_WINRT -# include -# endif -#endif - -#ifdef Q_OS_WINRT -#include -#include -#include -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Storage; +# include #endif #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_ANDROID) @@ -286,7 +274,7 @@ after_loop: return result; } -// see also qsettings_win.cpp, qsettings_winrt.cpp and qsettings_mac.cpp +// see also qsettings_win.cpp and qsettings_mac.cpp #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) && !defined(Q_OS_WASM) QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, QSettings::Scope scope, @@ -945,7 +933,7 @@ void QConfFileSettingsPrivate::initAccess() sync(); // loads the files the first time } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) static QString windowsConfigPath(const KNOWNFOLDERID &type) { QString result; @@ -966,44 +954,7 @@ static QString windowsConfigPath(const KNOWNFOLDERID &type) return result; } -#elif defined(Q_OS_WINRT) // Q_OS_WIN && !Q_OS_WINRT - -enum ConfigPathType { - ConfigPath_CommonAppData, - ConfigPath_UserAppData -}; - -static QString windowsConfigPath(ConfigPathType type) -{ - static QString result; - while (result.isEmpty()) { - ComPtr applicationDataStatics; - if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_ApplicationData).Get(), &applicationDataStatics))) - return result; - ComPtr applicationData; - if (FAILED(applicationDataStatics->get_Current(&applicationData))) - return result; - ComPtr localFolder; - if (FAILED(applicationData->get_LocalFolder(&localFolder))) - return result; - ComPtr localFolderItem; - if (FAILED(localFolder.As(&localFolderItem))) - return result; - HString path; - if (FAILED(localFolderItem->get_Path(path.GetAddressOf()))) - return result; - result = QString::fromWCharArray(path.GetRawBuffer(nullptr)); - } - - switch (type) { - case ConfigPath_CommonAppData: - return result + QLatin1String("\\qt-common"); - case ConfigPath_UserAppData: - return result + QLatin1String("\\qt-user"); - } - return result; -} -#endif // Q_OS_WINRT +#endif // Q_OS_WIN static inline int pathHashKey(QSettings::Format format, QSettings::Scope scope) { @@ -1056,14 +1007,8 @@ static std::unique_lock initDefaultPaths(std::unique_lockinsert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), Path(roamingAppDataFolder + QDir::separator(), false)); pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h index 8ddebd2359..548fcb591d 100644 --- a/src/corelib/io/qsettings_p.h +++ b/src/corelib/io/qsettings_p.h @@ -72,10 +72,6 @@ QT_BEGIN_NAMESPACE #define QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER #endif -#if defined(Q_OS_WINRT) -#define QT_QTSETTINGS_FORGET_ORIGINAL_KEY_ORDER -#endif - // used in testing framework #define QSETTINGS_P_H_VERSION 3 diff --git a/src/corelib/io/qsettings_winrt.cpp b/src/corelib/io/qsettings_winrt.cpp deleted file mode 100644 index a208262ab4..0000000000 --- a/src/corelib/io/qsettings_winrt.cpp +++ /dev/null @@ -1,690 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsettings.h" - -#include "qsettings_p.h" -#include "qvector.h" -#include "qmap.h" -#include "qdebug.h" -#include "qfunctions_winrt.h" - -#include -#include -#include -#include - -using namespace ABI::Windows::ApplicationModel; -using namespace ABI::Windows::Storage; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Foundation::Collections; -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; - -typedef ITypedEventHandler DataHandler; -typedef Collections::IKeyValuePair ContainerItem; -typedef Collections::IIterable ContainerIterable; -typedef Collections::IIterator ContainerIterator; - -typedef Collections::IKeyValuePair ValueItem; -typedef Collections::IIterable ValueIterable; -typedef Collections::IIterator ValueIterator; - -QT_BEGIN_NAMESPACE - -static IApplicationDataContainer *subContainer(IApplicationDataContainer *parent, const QString &name) -{ - ComPtr> childrenContainer; - HRESULT hr = parent->get_Containers(&childrenContainer); - if (FAILED(hr)) - return 0; - - ComPtr< ContainerIterable > iterable; - ComPtr< ContainerIterator > iterator; - - hr = childrenContainer.As(&iterable); - if (FAILED(hr)) - return 0; - - hr = iterable->First(&iterator); - if (FAILED(hr)) - return 0; - boolean current; - hr = iterator->get_HasCurrent(¤t); - if (FAILED(hr)) - return 0; - - while (SUCCEEDED(hr) && current) { - ComPtr item; - hr = iterator->get_Current(&item); - if (FAILED(hr)) - return 0; - - HString key; - hr = item->get_Key(key.GetAddressOf()); - if (FAILED(hr)) - continue; - QString subName = QString::fromWCharArray(key.GetRawBuffer(nullptr)); - if (name == subName) { - IApplicationDataContainer *container; - hr = item->get_Value(&container); - return SUCCEEDED(hr) ? container : 0; - } - hr = iterator->MoveNext(¤t); - } - - return 0; -} - -static QStringList subContainerNames(IApplicationDataContainer *container, bool recursive = false) -{ - QStringList result; - ComPtr> childrenContainer; - HRESULT hr = container->get_Containers(&childrenContainer); - if (FAILED(hr)) - return result; - - ComPtr< ContainerIterable > iterable; - ComPtr< ContainerIterator > iterator; - - hr = childrenContainer.As(&iterable); - if (FAILED(hr)) - return result; - - hr = iterable->First(&iterator); - if (FAILED(hr)) - return result; - boolean current; - hr = iterator->get_HasCurrent(¤t); - if (FAILED(hr)) - return result; - - while (SUCCEEDED(hr) && current) { - ComPtr item; - hr = iterator->get_Current(&item); - if (FAILED(hr)) - return result; - - HString key; - hr = item->get_Key(key.GetAddressOf()); - if (SUCCEEDED(hr)) { - QString subName = QString::fromWCharArray(key.GetRawBuffer(nullptr)); - result.append(subName); - if (recursive) { - ComPtr sub = subContainer(container, subName); - QStringList subSubNames = subContainerNames(sub.Get(), recursive); - for (int i = 0; i < subSubNames.size(); ++i) - subSubNames[i] = subName + QLatin1Char('/') + subSubNames[i]; - result.append(subSubNames); - } - hr = iterator->MoveNext(¤t); - } - } - return result; -} - -static QStringList keyNames(IApplicationDataContainer *container) { - HRESULT hr; - QStringList result; - ComPtr values; - hr = container->get_Values(&values); - if (FAILED(hr)) - return result; - - ComPtr> settingsMap; - - hr = values.As(&settingsMap); - if (FAILED(hr)) - return result; - - ComPtr> mapView; - hr = settingsMap->GetView(&mapView); - if (FAILED(hr)) - return result; - - ComPtr< ValueIterable > iterable; - ComPtr< ValueIterator > iterator; - - hr = mapView.As(&iterable); - if (FAILED(hr)) - return result; - - boolean current = false; - hr = iterable->First(&iterator); - if (FAILED(hr)) - return result; - hr = iterator->get_HasCurrent(¤t); - if (FAILED(hr)) - return result; - - while (SUCCEEDED(hr) && current){ - ComPtr item; - hr = iterator->get_Current(&item); - if (FAILED(hr)) - return result; - - HString key; - hr = item->get_Key(key.GetAddressOf()); - if (SUCCEEDED(hr)) { - result += QString::fromWCharArray(key.GetRawBuffer(nullptr)); - hr = iterator->MoveNext(¤t); - } - } - return result; -} - -static IApplicationDataContainer *createSubContainer(IApplicationDataContainer *parent, const QString &name) -{ - HStringReference childGroupNativeName((const wchar_t*)name.utf16(), name.size()); - - IApplicationDataContainer *result = subContainer(parent, name); - if (!result) - parent->CreateContainer(childGroupNativeName.Get(), ApplicationDataCreateDisposition_Always, &result); - return result; -} - -#define PROP_CASE_TO_VARIANT(TYPE, VARTYPE, QTYPE) \ - case PropertyType_##TYPE: { \ - VARTYPE v; \ - value->Get##TYPE(&v); \ - result.setValue( QTYPE(v) ); \ - break; \ - } - -static QVariant propertyValueToQVariant(IPropertyValue *value) -{ - QVariant result; - PropertyType type; - value->get_Type(&type); - switch (type) { - PROP_CASE_TO_VARIANT(Boolean, boolean, bool) - PROP_CASE_TO_VARIANT(UInt8, UINT8, quint8) - PROP_CASE_TO_VARIANT(Int16, INT16, qint16) - PROP_CASE_TO_VARIANT(UInt16, UINT16, quint16) - PROP_CASE_TO_VARIANT(Int32, INT32, qint32) - PROP_CASE_TO_VARIANT(UInt32, UINT32, quint32) - PROP_CASE_TO_VARIANT(Int64, INT64, qint64) - PROP_CASE_TO_VARIANT(UInt64, UINT64, quint64) - PROP_CASE_TO_VARIANT(Single, FLOAT, float) - PROP_CASE_TO_VARIANT(Double, DOUBLE, double) - case PropertyType_StringArray: { - UINT32 size; - HSTRING *content; - value->GetStringArray(&size, &content); - QStringList list; - // The last item is assumed to be added by us - for (UINT32 i = 0; i < size - 1; ++i) { - QString s = QString::fromWCharArray(WindowsGetStringRawBuffer(content[i], nullptr)); - list.append(s); - } - result = QSettingsPrivate::stringListToVariantList(list); - break; - } - case PropertyType_String: { - HString v; - value->GetString(v.GetAddressOf()); - result = QSettingsPrivate::stringToVariant(QString::fromWCharArray(v.GetRawBuffer(nullptr))); - break; - } - default: { - UINT32 size; - BYTE *arr; - value->GetUInt8Array(&size, &arr); - QByteArray data = QByteArray::fromRawData((const char*)arr, size); - QString s; - if (size) { - // We assume this is our qt stored data like on other platforms - // as well. QList and others are converted to byte arrays - s = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2); - result = QSettingsPrivate::stringToVariant(s); - } - break; - } - } - return result; -} - -class QWinRTSettingsPrivate : public QSettingsPrivate -{ -public: - QWinRTSettingsPrivate(QSettings::Scope scope, const QString &organization, - const QString &application); - QWinRTSettingsPrivate(const QString &rKey); - ~QWinRTSettingsPrivate(); - - void remove(const QString &uKey) override; - void set(const QString &uKey, const QVariant &value) override; - bool get(const QString &uKey, QVariant *value) const override; - QStringList children(const QString &uKey, ChildSpec spec) const override; - void clear() override; - void sync() override; - void flush() override; - bool isWritable() const override; - QString fileName() const override; - -private: - void init(QSettings::Scope scope); - IApplicationDataContainer *getContainer(IApplicationDataContainer *parent, const QString &group, bool create = false) const; - void clearContainerMaps(); - - HRESULT onDataChanged(IApplicationData*, IInspectable*); - - ComPtr applicationData; - QVector> readContainers; - ComPtr writeContainer; - EventRegistrationToken dataChangedToken; -}; - -QWinRTSettingsPrivate::QWinRTSettingsPrivate(QSettings::Scope scope, const QString &organization, - const QString &application) - : QSettingsPrivate(QSettings::NativeFormat, scope, organization, application) - , writeContainer(0) -{ - init(scope); -} - -QWinRTSettingsPrivate::QWinRTSettingsPrivate(const QString &rPath) - : QSettingsPrivate(QSettings::NativeFormat, QSettings::UserScope, rPath, QString()) - , writeContainer(0) -{ - init(QSettings::UserScope); -} - -QWinRTSettingsPrivate::~QWinRTSettingsPrivate() -{ - clearContainerMaps(); -} - -void QWinRTSettingsPrivate::remove(const QString &uKey) -{ - int lastIndex = uKey.lastIndexOf(QLatin1Char('/')); - QString groupName = (lastIndex > 0) ? uKey.left(lastIndex) : QString(); - QString groupKey = uKey.mid(lastIndex + 1); - - ComPtr container = getContainer(writeContainer.Get(), groupName, false); - if (!container) - return; - - HRESULT hr; - ComPtr values; - hr = container->get_Values(&values); - if (FAILED(hr)) - return; - - ComPtr> settingsMap; - - hr = values.As(&settingsMap); - if (FAILED(hr)) - return; - - HStringReference ref((const wchar_t*)groupKey.utf16(), groupKey.size()); - hr = settingsMap->Remove(ref.Get()); - - // groupKey can be a container as well - hr = container->DeleteContainer(ref.Get()); - init(scope); -} - -void QWinRTSettingsPrivate::set(const QString &uKey, const QVariant &value) -{ - int lastIndex = uKey.lastIndexOf(QLatin1Char('/')); - QString groupName = (lastIndex > 0) ? uKey.left(lastIndex) : QString(); - QString groupKey = uKey.mid(lastIndex + 1); - - ComPtr container = getContainer(writeContainer.Get(), groupName, true); - - ComPtr values; - HRESULT hr = container->get_Values(&values); - if (FAILED(hr)) { - qErrnoWarning(hr, "Could not access Windows container values"); - setStatus(QSettings::AccessError); - return; - } - - ComPtr> settingsMap; - hr = values.As(&settingsMap); - if (FAILED(hr)) { - setStatus(QSettings::AccessError); - return; - } - - ComPtr valueStatics; - hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Foundation_PropertyValue).Get(), &valueStatics); - if (FAILED(hr)) { - setStatus(QSettings::AccessError); - return; - } - - ComPtr val; - - switch (value.type()) { - case QVariant::List: - case QVariant::StringList: { - QStringList l = variantListToStringList(value.toList()); - QStringList::const_iterator it = l.constBegin(); - bool containsNull = false; - for (; it != l.constEnd(); ++it) { - if ((*it).length() == 0 || it->contains(QChar::Null)) { - // We can only store as binary - containsNull = true; - break; - } - } - - if (containsNull) { - // Store binary - const QString s = variantToString(value); - hr = valueStatics->CreateUInt8Array(s.length() * 2, (BYTE*) s.utf16(), &val); - } else { - // Store as native string list - int size = l.size(); - HSTRING *nativeHandleList = new HSTRING[size+1]; - for (int i = 0; i < size; ++i) - hr = WindowsCreateString((const wchar_t*)l[i].utf16(), l[i].size(), &nativeHandleList[i]); - // Add end marker - hr = WindowsCreateString((const wchar_t*)L"\0\0@", 3, &nativeHandleList[size]); - hr = valueStatics->CreateStringArray(size + 1 , nativeHandleList, &val); - for (int i = 0; i < size; ++i) - hr = WindowsDeleteString(nativeHandleList[i]); - delete [] nativeHandleList; - } - break; - } - case QVariant::Bool: - hr = valueStatics->CreateBoolean(boolean(value.toBool()), &val); - break; - case QVariant::Int: - hr = valueStatics->CreateInt32(INT32(value.toInt()), &val); - break; - case QVariant::UInt: - hr = valueStatics->CreateUInt32(UINT32(value.toUInt()), &val); - break; - case QVariant::LongLong: - hr = valueStatics->CreateInt64(INT64(value.toLongLong()), &val); - break; - case QVariant::ULongLong: - hr = valueStatics->CreateUInt64(UINT64(value.toULongLong()), &val); - break; - default: { - const QString s = variantToString(value); - if (s.contains(QChar::Null)) { - hr = valueStatics->CreateUInt8Array(s.length() * 2, (BYTE*) s.utf16(), &val); - } else { - HStringReference ref((const wchar_t*)s.utf16(), s.size()); - hr = valueStatics->CreateString(ref.Get(), &val); - } - - break; - } - } - - RETURN_VOID_IF_FAILED("QSettings: Could not save QVariant value into IInspectable"); - - HStringReference key((const wchar_t*)groupKey.utf16(), groupKey.size()); - boolean rep; - - hr = settingsMap->Insert(key.Get(), val.Get(), &rep); - RETURN_VOID_IF_FAILED("QSettings: Could not store value"); -} - -bool QWinRTSettingsPrivate::get(const QString &uKey, QVariant *value) const -{ - int lastIndex = uKey.lastIndexOf(QLatin1Char('/')); - QString groupName = (lastIndex > 0) ? uKey.left(lastIndex) : QString(); - QString groupKey = uKey.mid(lastIndex + 1); - - HRESULT hr; - - for (int i = 0; i < readContainers.size(); ++i) { - ComPtr container = const_cast(this)->getContainer(readContainers.at(i).Get(), groupName); - - if (!container) - continue; - - ComPtr values; - hr = container->get_Values(&values); - if (FAILED(hr)) - continue; - - ComPtr> settingsMap; - hr = values.As(&settingsMap); - if (FAILED(hr)) - continue; - - HStringReference key((const wchar_t*)groupKey.utf16(), groupKey.size()); - boolean exists; - - hr = settingsMap.Get()->HasKey(key.Get(), &exists); - if (FAILED(hr)) - continue; - - if (!exists) { - if (!fallbacks) - break; - else - continue; - } - - if (value) { - ComPtr val; - hr = settingsMap->Lookup(key.Get(), &val); - if (FAILED(hr)) - return false; - - ComPtr pVal; - hr = val.As(&pVal); - if (FAILED(hr)) - return false; - - *value = propertyValueToQVariant(pVal.Get()); - } - return true; - } - setStatus(QSettings::AccessError); - return false; -} - -QStringList QWinRTSettingsPrivate::children(const QString &uKey, ChildSpec spec) const -{ - QStringList result; - for (int i = 0; i < readContainers.size(); ++i) { - ComPtr container = getContainer(readContainers.at(i).Get(), uKey, false); - if (!container.Get()) - continue; - - // Get Keys in this container - if (spec == AllKeys || spec == ChildKeys) - result += keyNames(container.Get()); - - // Get Subcontainer(s) - if (spec == AllKeys || spec == ChildGroups) { - const QStringList subContainerList = subContainerNames(container.Get(), spec == AllKeys); - - if (spec == AllKeys) { - for (const QString &item : subContainerList) { - const QString subChildren = uKey.isEmpty() ? item : (uKey + QLatin1Char('/') + item); - const QStringList subResult = children(subChildren, ChildKeys); - for (const QString &subItem : subResult) - result += item + QLatin1Char('/') + subItem; - } - } - - if (spec == ChildGroups) - result += subContainerList; - } - - } - result.removeDuplicates(); - return result; -} - -void QWinRTSettingsPrivate::clear() -{ - ComPtr container; - HRESULT hr; - if (scope == QSettings::UserScope) - hr = applicationData->get_LocalSettings(&container); - else - hr = applicationData->get_RoamingSettings(&container); - - RETURN_VOID_IF_FAILED("Could not access settings container"); - - QString containerName = applicationName.isEmpty() ? organizationName : applicationName; - HStringReference containerNativeName((const wchar_t*)containerName.utf16(), containerName.size()); - - hr = container->DeleteContainer(containerNativeName.Get()); - RETURN_VOID_IF_FAILED("Could not delete Container"); - - init(scope); -} - -void QWinRTSettingsPrivate::sync() -{ - // No native sync available -} - -void QWinRTSettingsPrivate::flush() -{ - // No native flush available -} - -QString QWinRTSettingsPrivate::fileName() const -{ - Q_UNIMPLEMENTED(); - return QString(); -} - -HRESULT QWinRTSettingsPrivate::onDataChanged(IApplicationData *, IInspectable *) -{ - // This only happens, if roaming data is changed by the OS. - // To ensure sanity we clean up the map and start from scratch - init(scope); - return S_OK; -} - -void QWinRTSettingsPrivate::init(QSettings::Scope scope) -{ - clearContainerMaps(); - - ComPtr applicationDataStatics; - HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_ApplicationData).Get(), &applicationDataStatics); - if (FAILED(hr)) { - qErrnoWarning(hr, "Could not access Storage Factory"); - setStatus(QSettings::AccessError); - return; - } - - hr = applicationDataStatics->get_Current(&applicationData); - if (FAILED(hr)) { - qErrnoWarning(hr, "Could not access application data statics"); - setStatus(QSettings::AccessError); - return; - } - - const QString organizationString = organizationName.isEmpty() ? QLatin1String("OrganizationDefaults") : organizationName; - ComPtr localContainer; - if (scope == QSettings::UserScope && SUCCEEDED(applicationData->get_LocalSettings(&localContainer))) { - if (!applicationName.isEmpty()) - readContainers.append(createSubContainer(localContainer.Get(), applicationName)); - readContainers.append(createSubContainer(localContainer.Get(), organizationString)); - } - - ComPtr roamingContainer; - if (SUCCEEDED(applicationData->get_RoamingSettings(&roamingContainer))) { - if (!applicationName.isEmpty()) - readContainers.append(createSubContainer(roamingContainer.Get(), applicationName)); - readContainers.append(createSubContainer(roamingContainer.Get(), organizationString)); - } - - ComPtr writeRootContainer = (scope == QSettings::UserScope) ? localContainer : roamingContainer; - if (!applicationName.isEmpty()) - writeContainer = createSubContainer(writeRootContainer.Get(), applicationName); - else - writeContainer = createSubContainer(writeRootContainer.Get(), organizationString); - - hr = applicationData->add_DataChanged(Callback(this, &QWinRTSettingsPrivate::onDataChanged).Get(), &dataChangedToken); -} - -IApplicationDataContainer *QWinRTSettingsPrivate::getContainer(IApplicationDataContainer *parent, const QString &group, bool create) const -{ - IApplicationDataContainer *current = parent; - if (group.isEmpty()) - return current; - const QStringList groupPath = group.split(QLatin1Char('/'), Qt::SkipEmptyParts); - - for (const QString &subGroup : groupPath) { - ComPtr sub = subContainer(current, subGroup); - if (!sub && create) - sub = createSubContainer(current, subGroup); - if (!sub) - return 0; // Something seriously went wrong - current = sub.Detach(); - } - return current; -} - -void QWinRTSettingsPrivate::clearContainerMaps() -{ - readContainers.clear(); - writeContainer.Reset(); -} - -bool QWinRTSettingsPrivate::isWritable() const -{ - return true; -} - -QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, QSettings::Scope scope, - const QString &organization, const QString &application) -{ - if (format == QSettings::NativeFormat) - return new QWinRTSettingsPrivate(scope, organization, application); - else - return new QConfFileSettingsPrivate(format, scope, organization, application); -} - -QSettingsPrivate *QSettingsPrivate::create(const QString &fileName, QSettings::Format format) -{ - if (format == QSettings::NativeFormat) - return new QWinRTSettingsPrivate(fileName); - else - return new QConfFileSettingsPrivate(fileName, format); -} - -QT_END_NAMESPACE diff --git a/src/corelib/io/qstandardpaths_winrt.cpp b/src/corelib/io/qstandardpaths_winrt.cpp deleted file mode 100644 index a7de15472e..0000000000 --- a/src/corelib/io/qstandardpaths_winrt.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qstandardpaths.h" - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -using namespace Microsoft::WRL; -using namespace Microsoft::WRL::Wrappers; -using namespace ABI::Windows::Foundation; -using namespace ABI::Windows::Storage; -using namespace ABI::Windows::ApplicationModel; - -#ifndef QT_NO_STANDARDPATHS - -QT_BEGIN_NAMESPACE - -static QString convertCharArray(const wchar_t *path) -{ - return QDir::fromNativeSeparators(QString::fromWCharArray(path)); -} - -QString QStandardPaths::writableLocation(StandardLocation type) -{ - QString result; - - switch (type) { - case ConfigLocation: // same as AppLocalDataLocation, on Windows - case GenericConfigLocation: // same as GenericDataLocation, on Windows - case AppConfigLocation: - case AppDataLocation: - case AppLocalDataLocation: - case GenericDataLocation: { - ComPtr applicationDataStatics; - if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_ApplicationData).Get(), &applicationDataStatics))) - break; - ComPtr applicationData; - if (FAILED(applicationDataStatics->get_Current(&applicationData))) - break; - ComPtr settingsFolder; - if (FAILED(applicationData->get_LocalFolder(&settingsFolder))) - break; - ComPtr settingsFolderItem; - if (FAILED(settingsFolder.As(&settingsFolderItem))) - break; - HString path; - if (FAILED(settingsFolderItem->get_Path(path.GetAddressOf()))) - break; - result = convertCharArray(path.GetRawBuffer(nullptr)); - if (isTestModeEnabled()) - result += QLatin1String("/qttest"); - break; - } - case CacheLocation: - return writableLocation(AppLocalDataLocation) + QLatin1String("/cache"); - - case GenericCacheLocation: - return writableLocation(GenericDataLocation) + QLatin1String("/cache"); - - case TempLocation: - result = QDir::tempPath(); - break; - - case ApplicationsLocation: - case DesktopLocation: - case FontsLocation: - case HomeLocation: - case RuntimeLocation: - // these are read-only - break; - - case DocumentsLocation: - case MusicLocation: - case MoviesLocation: - case PicturesLocation: - case DownloadLocation: - default: - Q_UNIMPLEMENTED(); - } - return result; - -} - -QStringList QStandardPaths::standardLocations(StandardLocation type) -{ - const QString writable = writableLocation(type); - return writable.isEmpty() ? QStringList() : QStringList(writable); -} - -QT_END_NAMESPACE - -#endif // QT_NO_STANDARDPATHS diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h index ec5bb785e3..421e364311 100644 --- a/src/corelib/io/qstorageinfo_p.h +++ b/src/corelib/io/qstorageinfo_p.h @@ -71,7 +71,7 @@ public: static QStorageInfo root(); protected: -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) void retrieveVolumeInfo(); void retrieveDiskFreeSpace(); #elif defined(Q_OS_MAC) diff --git a/src/corelib/io/qstorageinfo_stub.cpp b/src/corelib/io/qstorageinfo_stub.cpp deleted file mode 100644 index a312b9dc89..0000000000 --- a/src/corelib/io/qstorageinfo_stub.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ivan Komissarov -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qstorageinfo_p.h" - -QT_BEGIN_NAMESPACE - -void QStorageInfoPrivate::initRootPath() -{ - Q_UNIMPLEMENTED(); - rootPath = QString(); -} - -void QStorageInfoPrivate::doStat() -{ - Q_UNIMPLEMENTED(); -} - -QList QStorageInfoPrivate::mountedVolumes() -{ - Q_UNIMPLEMENTED(); - return QList(); -} - -QStorageInfo QStorageInfoPrivate::root() -{ - Q_UNIMPLEMENTED(); - return QStorageInfo(); -} - -QT_END_NAMESPACE diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index c016a622c7..e6a160c3b2 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -219,17 +219,10 @@ static bool createFileFromTemplate(NativeFileHandle &file, QTemporaryFileName &t const DWORD shareMode = (flags & QTemporaryFileEngine::Win32NonShared) ? 0u : (FILE_SHARE_READ | FILE_SHARE_WRITE); -# ifndef Q_OS_WINRT file = CreateFile((const wchar_t *)path.constData(), GENERIC_READ | GENERIC_WRITE, shareMode, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); -# else // !Q_OS_WINRT - file = CreateFile2((const wchar_t *)path.constData(), - GENERIC_READ | GENERIC_WRITE, - shareMode, CREATE_NEW, - NULL); -# endif // Q_OS_WINRT if (file != INVALID_HANDLE_VALUE) return true; @@ -380,7 +373,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) return false; } -#if !defined(Q_OS_WIN) || defined(Q_OS_WINRT) +#if !defined(Q_OS_WIN) d->closeFileHandle = true; #endif -- cgit v1.2.3