diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-04-24 16:32:49 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-29 12:28:16 +0200 |
commit | f3bc9f5c5cee9dac8a7815c2861a9945b5341390 (patch) | |
tree | c7306c4c04013e9290df292cecd5af24c9dcbd90 /src/corelib/io/qstandardpaths_win.cpp | |
parent | 32893fa9c45ad1a26a476f43711bdd5e6951e24b (diff) |
Add locations AppDataLocation, AppLocalDataLocation to QStandardPaths.
On Windows, DataLocation currently returns the value obtained by
passing CSIDL_COMMON_APPDATA to SHGetSpecialFolderPath(). This is
the local non-roaming path. For actually storing settings, the roaming
path should be used (CSIDL_APPDATA). Introduce new AppDataLocation to
return that path and AppLocalDataLocation for the local path and deprecate
DataLocation.
[ChangeLog][QtCore][QStandardPaths] QStandardPaths now has new
enumeration values AppDataLocation, AppLocalDataLocation to be able
to differentiate between roaming and local paths on the Windows
operating system. DataLocation is deprecated in favor of AppDataLocation.
Task-number: QTBUG-38483
Change-Id: Ib1de8c7031a863ed5eac10c747de6f7ff1a090c7
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/io/qstandardpaths_win.cpp')
-rw-r--r-- | src/corelib/io/qstandardpaths_win.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index 062ab49207..aaa390ac34 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -81,6 +81,18 @@ static QString convertCharArray(const wchar_t *path) return QDir::fromNativeSeparators(QString::fromWCharArray(path)); } +static inline int clsidForAppDataLocation(QStandardPaths::StandardLocation type) +{ +#ifndef Q_OS_WINCE + return type == QStandardPaths::AppDataLocation ? + CSIDL_APPDATA : // "Roaming" path + CSIDL_LOCAL_APPDATA; // Local path +#else + Q_UNUSED(type) + return CSIDL_APPDATA; +#endif +} + QString QStandardPaths::writableLocation(StandardLocation type) { QString result; @@ -92,15 +104,12 @@ QString QStandardPaths::writableLocation(StandardLocation type) wchar_t path[MAX_PATH]; switch (type) { - case ConfigLocation: // same as DataLocation, on Windows (oversight, but too late to fix it) - case GenericConfigLocation: // same as GenericDataLocation, on Windows - case DataLocation: + case ConfigLocation: // same as AppLocalDataLocation, on Windows + case GenericConfigLocation: // same as GenericDataLocation on Windows + case AppDataLocation: + case AppLocalDataLocation: case GenericDataLocation: -#if defined Q_OS_WINCE - if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE)) -#else - if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE)) -#endif + if (SHGetSpecialFolderPath(0, path, clsidForAppDataLocation(type), FALSE)) result = convertCharArray(path); if (isTestModeEnabled()) result += QLatin1String("/qttest"); @@ -165,7 +174,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 - return writableLocation(DataLocation) + QLatin1String("/cache"); + return writableLocation(AppLocalDataLocation) + QLatin1String("/cache"); case GenericCacheLocation: return writableLocation(GenericDataLocation) + QLatin1String("/cache"); @@ -192,11 +201,12 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) { wchar_t path[MAX_PATH]; switch (type) { - case ConfigLocation: // same as DataLocation, on Windows (oversight, but too late to fix it) + case ConfigLocation: // same as AppLocalDataLocation, on Windows (oversight, but too late to fix it) case GenericConfigLocation: // same as GenericDataLocation, on Windows - case DataLocation: + case AppDataLocation: + case AppLocalDataLocation: case GenericDataLocation: - if (SHGetSpecialFolderPath(0, path, CSIDL_COMMON_APPDATA, FALSE)) { + if (SHGetSpecialFolderPath(0, path, clsidForAppDataLocation(type), FALSE)) { QString result = convertCharArray(path); if (type != GenericDataLocation && type != GenericConfigLocation) { #ifndef QT_BOOTSTRAPPED |