summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfilesystemengine.cpp4
-rw-r--r--src/corelib/io/qfilesystemiterator_p.h8
-rw-r--r--src/corelib/io/qfilesystemiterator_unix.cpp38
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp79
-rw-r--r--src/corelib/io/qurl.cpp2
5 files changed, 32 insertions, 99 deletions
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index 6424012a9a..ccbcdb1037 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -222,7 +222,7 @@ bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data)
return false;
}
-#if defined(QT_EXT_QNX_READDIR_R)
+#if defined(_DEXTRA_FIRST)
static void fillStat64fromStat32(struct stat64 *statBuf64, const struct stat &statBuf32)
{
statBuf64->st_mode = statBuf32.st_mode;
@@ -308,7 +308,7 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
void QFileSystemMetaData::fillFromDirEnt(const QT_DIRENT &entry)
{
-#if defined(QT_EXT_QNX_READDIR_R)
+#if defined(_DEXTRA_FIRST)
knownFlagsMask = 0;
entryFlags = 0;
for (dirent_extra *extra = _DEXTRA_FIRST(&entry); _DEXTRA_VALID(extra, &entry);
diff --git a/src/corelib/io/qfilesystemiterator_p.h b/src/corelib/io/qfilesystemiterator_p.h
index 16830257e1..081487e66e 100644
--- a/src/corelib/io/qfilesystemiterator_p.h
+++ b/src/corelib/io/qfilesystemiterator_p.h
@@ -93,14 +93,6 @@ private:
#else
QT_DIR *dir;
QT_DIRENT *dirEntry;
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) || defined(QT_EXT_QNX_READDIR_R)
- // for readdir_r
- QScopedPointer<QT_DIRENT, QScopedPointerPodDeleter> mt_file;
-#if defined(QT_EXT_QNX_READDIR_R)
- // for _readdir_r
- size_t direntSize;
-#endif
-#endif
int lastError;
#endif
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp
index d7b21fac32..0d1438f137 100644
--- a/src/corelib/io/qfilesystemiterator_unix.cpp
+++ b/src/corelib/io/qfilesystemiterator_unix.cpp
@@ -52,9 +52,6 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi
: nativePath(entry.nativeFilePath())
, dir(0)
, dirEntry(0)
-#if defined(Q_OS_QNX) && defined(__EXT_QNX__READDIR_R)
- , direntSize(0)
-#endif
, lastError(0)
{
Q_UNUSED(filters)
@@ -64,32 +61,8 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi
if ((dir = QT_OPENDIR(nativePath.constData())) == 0) {
lastError = errno;
} else {
-
if (!nativePath.endsWith('/'))
nativePath.append('/');
-
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) || defined(QT_EXT_QNX_READDIR_R)
- // ### Race condition; we should use fpathconf and dirfd().
- size_t maxPathName = ::pathconf(nativePath.constData(), _PC_NAME_MAX);
- if (maxPathName == size_t(-1))
- maxPathName = FILENAME_MAX;
- maxPathName += sizeof(QT_DIRENT) + 1;
-
- QT_DIRENT *p = reinterpret_cast<QT_DIRENT*>(::malloc(maxPathName));
- Q_CHECK_PTR(p);
-
- mt_file.reset(p);
-#if defined(QT_EXT_QNX_READDIR_R)
- direntSize = maxPathName;
-
- // Include extra stat information in the readdir() call (d_stat member of
- // dirent_extra_stat). This is used in QFileSystemMetaData::fillFromDirEnt() to
- // avoid extra stat() calls when iterating over directories
- int flags = dircntl(dir, D_GETFLAG) | D_FLAG_STAT | D_FLAG_FILTER;
- if (dircntl(dir, D_SETFLAG, flags) == -1)
- lastError = errno;
-#endif
-#endif
}
}
@@ -104,18 +77,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
if (!dir)
return false;
-#if defined(QT_EXT_QNX_READDIR_R)
- lastError = QT_EXT_QNX_READDIR_R(dir, mt_file.data(), &dirEntry, direntSize);
- if (lastError)
- return false;
-#elif defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
- lastError = QT_READDIR_R(dir, mt_file.data(), &dirEntry);
- if (lastError)
- return false;
-#else
- // ### add local lock to prevent breaking reentrancy
dirEntry = QT_READDIR(dir);
-#endif // _POSIX_THREAD_SAFE_FUNCTIONS
if (dirEntry) {
fileEntry = QFileSystemEntry(nativePath + QByteArray(dirEntry->d_name), QFileSystemEntry::FromNativePath());
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index 38c63553ea..a64bde6fb4 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -47,17 +47,10 @@
#include <qcoreapplication.h>
#endif
-const GUID qCLSID_FOLDERID_Downloads = { 0x374de290, 0x123f, 0x4565, { 0x91, 0x64, 0x39, 0xc4, 0x92, 0x5e, 0x46, 0x7b } };
-
#include <qt_windows.h>
#include <shlobj.h>
#include <intshcut.h>
-#ifndef CSIDL_MYMUSIC
-#define CSIDL_MYMUSIC 13
-#define CSIDL_MYVIDEO 14
-#endif
-
#ifndef QT_NO_STANDARDPATHS
QT_BEGIN_NAMESPACE
@@ -108,47 +101,31 @@ static inline void appendTestMode(QString &path)
path += QLatin1String("/qttest");
}
-// Map QStandardPaths::StandardLocation to CLSID of SHGetSpecialFolderPath()
-static int writableSpecialFolderClsid(QStandardPaths::StandardLocation type)
+// Map QStandardPaths::StandardLocation to KNOWNFOLDERID of SHGetKnownFolderPath()
+static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type)
{
- static const int clsids[] = {
- CSIDL_DESKTOPDIRECTORY, // DesktopLocation
- CSIDL_PERSONAL, // DocumentsLocation
- CSIDL_FONTS, // FontsLocation
- CSIDL_PROGRAMS, // ApplicationsLocation
- CSIDL_MYMUSIC, // MusicLocation
- CSIDL_MYVIDEO, // MoviesLocation
- CSIDL_MYPICTURES, // PicturesLocation
- -1, -1, // TempLocation/HomeLocation
- CSIDL_LOCAL_APPDATA, // AppLocalDataLocation ("Local" path), AppLocalDataLocation = DataLocation
- -1, // CacheLocation
- CSIDL_LOCAL_APPDATA, // GenericDataLocation ("Local" path)
- -1, // RuntimeLocation
- CSIDL_LOCAL_APPDATA, // ConfigLocation ("Local" path)
- -1, -1, // DownloadLocation/GenericCacheLocation
- CSIDL_LOCAL_APPDATA, // GenericConfigLocation ("Local" path)
- CSIDL_APPDATA, // AppDataLocation ("Roaming" path)
- CSIDL_LOCAL_APPDATA, // AppConfigLocation ("Local" path)
+ static const GUID folderIds[] = {
+ FOLDERID_Desktop, // DesktopLocation
+ FOLDERID_Documents, // DocumentsLocation
+ FOLDERID_Fonts, // FontsLocation
+ FOLDERID_Programs, // ApplicationsLocation
+ FOLDERID_Music, // MusicLocation
+ FOLDERID_Videos, // MoviesLocation
+ FOLDERID_Pictures, // PicturesLocation
+ GUID(), GUID(), // TempLocation/HomeLocation
+ FOLDERID_LocalAppData, // AppLocalDataLocation ("Local" path), AppLocalDataLocation = DataLocation
+ GUID(), // CacheLocation
+ FOLDERID_LocalAppData, // GenericDataLocation ("Local" path)
+ GUID(), // RuntimeLocation
+ FOLDERID_LocalAppData, // ConfigLocation ("Local" path)
+ GUID(), GUID(), // DownloadLocation/GenericCacheLocation
+ FOLDERID_LocalAppData, // GenericConfigLocation ("Local" path)
+ FOLDERID_RoamingAppData,// AppDataLocation ("Roaming" path)
+ FOLDERID_LocalAppData, // AppConfigLocation ("Local" path)
};
- Q_STATIC_ASSERT(sizeof(clsids) / sizeof(clsids[0]) == size_t(QStandardPaths::AppConfigLocation + 1));
- return size_t(type) < sizeof(clsids) / sizeof(clsids[0]) ? clsids[type] : -1;
-};
-
-// Convenience for SHGetSpecialFolderPath().
-static QString sHGetSpecialFolderPath(int clsid, QStandardPaths::StandardLocation type, bool warn = false)
-{
- QString result;
- wchar_t path[MAX_PATH];
- if (Q_LIKELY(clsid >= 0 && SHGetSpecialFolderPath(0, path, clsid, FALSE))) {
- result = convertCharArray(path);
- } else {
- if (warn) {
- qErrnoWarning("SHGetSpecialFolderPath() failed for standard location \"%s\", clsid=0x%x.",
- qPrintable(displayName(type)), clsid);
- }
- }
- return result;
+ Q_STATIC_ASSERT(sizeof(folderIds) / sizeof(folderIds[0]) == size_t(QStandardPaths::AppConfigLocation + 1));
+ return size_t(type) < sizeof(folderIds) / sizeof(folderIds[0]) ? folderIds[type] : GUID();
}
// Convenience for SHGetKnownFolderPath().
@@ -161,7 +138,7 @@ static QString sHGetKnownFolderPath(const GUID &clsid, QStandardPaths::StandardL
reinterpret_cast<GetKnownFolderPath>(QSystemLibrary::resolve(QLatin1String("shell32"), "SHGetKnownFolderPath"));
LPWSTR path;
- if (Q_LIKELY(sHGetKnownFolderPath && SUCCEEDED(sHGetKnownFolderPath(clsid, 0, 0, &path)))) {
+ if (Q_LIKELY(sHGetKnownFolderPath && SUCCEEDED(sHGetKnownFolderPath(clsid, KF_FLAG_DONT_VERIFY, 0, &path)))) {
result = convertCharArray(path);
CoTaskMemFree(path);
} else {
@@ -178,7 +155,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
QString result;
switch (type) {
case DownloadLocation:
- result = sHGetKnownFolderPath(qCLSID_FOLDERID_Downloads, type);
+ result = sHGetKnownFolderPath(FOLDERID_Downloads, type);
if (result.isEmpty())
result = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
break;
@@ -187,7 +164,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
// Although Microsoft has a Cache key it is a pointer to IE's cache, not a cache
// location for everyone. Most applications seem to be using a
// cache directory located in their AppData directory
- result = sHGetSpecialFolderPath(writableSpecialFolderClsid(AppLocalDataLocation), type, /* warn */ true);
+ result = sHGetKnownFolderPath(writableSpecialFolderId(AppLocalDataLocation), type, /* warn */ true);
if (!result.isEmpty()) {
appendTestMode(result);
appendOrganizationAndApp(result);
@@ -196,7 +173,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
break;
case GenericCacheLocation:
- result = sHGetSpecialFolderPath(writableSpecialFolderClsid(GenericDataLocation), type, /* warn */ true);
+ result = sHGetKnownFolderPath(writableSpecialFolderId(GenericDataLocation), type, /* warn */ true);
if (!result.isEmpty()) {
appendTestMode(result);
result += QLatin1String("/cache");
@@ -213,7 +190,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
break;
default:
- result = sHGetSpecialFolderPath(writableSpecialFolderClsid(type), type, /* warn */ isConfigLocation(type));
+ result = sHGetKnownFolderPath(writableSpecialFolderId(type), type, /* warn */ isConfigLocation(type));
if (!result.isEmpty() && isConfigLocation(type)) {
appendTestMode(result);
if (!isGenericConfigLocation(type))
@@ -233,7 +210,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
// type-specific handling goes here
if (isConfigLocation(type)) {
- QString programData = sHGetSpecialFolderPath(CSIDL_COMMON_APPDATA, type);
+ QString programData = sHGetKnownFolderPath(FOLDERID_ProgramData, type);
if (!programData.isEmpty()) {
if (!isGenericConfigLocation(type))
appendOrganizationAndApp(programData);
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index b7762c2ae6..5b34813a71 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -410,7 +410,9 @@
#include "qhash.h"
#include "qdir.h" // for QDir::fromNativeSeparators
#include "qdatastream.h"
+#if QT_CONFIG(topleveldomain)
#include "qtldurl_p.h"
+#endif
#include "private/qipaddress_p.h"
#include "qurlquery.h"