summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2011-10-21 20:12:01 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-23 00:56:31 +0200
commit86558de34134f67cf3815a29612edc2d730f2ea2 (patch)
tree868417b17bac24be1f17080680af0f614a98b9b6 /src/corelib
parent4a788eb8313d7c089e3a59594fc6a5c9a7dd6499 (diff)
Move path information from QDesktopServices (gui) to QStandardPaths (core)
Change-Id: Ic596c21894d83b4dab0c3f5b1aed916ddd590f2f Reviewed-by: Thiago Macieira (Intel) <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/io.pri8
-rw-r--r--src/corelib/io/qstandardpaths.cpp114
-rw-r--r--src/corelib/io/qstandardpaths.h85
-rw-r--r--src/corelib/io/qstandardpaths_mac.cpp148
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp166
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp167
6 files changed, 688 insertions, 0 deletions
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index e411f8f643..6d7a59d1b3 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -23,6 +23,7 @@ HEADERS += \
io/qtemporaryfile.h \
io/qresource_p.h \
io/qresource_iterator_p.h \
+ io/qstandardpaths.h \
io/qurl.h \
io/qurltlds_p.h \
io/qtldurl_p.h \
@@ -56,6 +57,7 @@ SOURCES += \
io/qtemporaryfile.cpp \
io/qresource.cpp \
io/qresource_iterator.cpp \
+ io/qstandardpaths.cpp \
io/qurl.cpp \
io/qsettings.cpp \
io/qfsfileengine.cpp \
@@ -75,6 +77,7 @@ win32 {
SOURCES += io/qwindowspipewriter.cpp
SOURCES += io/qfilesystemengine_win.cpp
SOURCES += io/qfilesystemiterator_win.cpp
+ SOURCES += io/qstandardpaths_win.cpp
} else:unix {
SOURCES += io/qfsfileengine_unix.cpp
symbian {
@@ -91,6 +94,11 @@ win32 {
SOURCES += io/qfilesystemengine_mac.cpp
SOURCES += io/qsettings_mac.cpp io/qfilesystemwatcher_fsevents.cpp
}
+ macx-*: {
+ SOURCES += io/qstandardpaths_mac.cpp
+ } else {
+ SOURCES += io/qstandardpaths_unix.cpp
+ }
linux-*:!symbian {
SOURCES += \
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
new file mode 100644
index 0000000000..e441a21c11
--- /dev/null
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstandardpaths.h"
+
+#include <qdir.h>
+#include <qfileinfo.h>
+#include <qhash.h>
+#include <qobject.h>
+#include <qcoreapplication.h>
+
+#ifndef QT_NO_STANDARDPATHS
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QStandardPaths
+ \brief The QStandardPaths class provides methods for accessing standard paths.
+ \since 5.0
+
+ This class contains functions to query standard locations on the local
+ filesystem, for common tasks such as user-specific directories or system-wide
+ configuration directories.
+*/
+
+/*!
+ \enum QStandardPaths::StandardLocation
+
+ This enum describes the different locations that can be queried using
+ methods such as QStandardPaths::storageLocation and QStandardPaths::displayName.
+
+ \value DesktopLocation Returns the user's desktop directory.
+ \value DocumentsLocation Returns the user's document.
+ \value FontsLocation Returns the user's fonts.
+ \value ApplicationsLocation Returns the user's applications.
+ \value MusicLocation Returns the users music.
+ \value MoviesLocation Returns the user's movies.
+ \value PicturesLocation Returns the user's pictures.
+ \value TempLocation Returns the system's temporary directory.
+ \value HomeLocation Returns the user's home directory.
+ \value DataLocation Returns a directory location where persistent
+ application data can be stored. QCoreApplication::applicationName
+ and QCoreApplication::organizationName should work on all
+ platforms.
+ \value CacheLocation Returns a directory location where user-specific
+ non-essential (cached) data should be written.
+
+ \sa storageLocation() displayName()
+*/
+
+/*!
+ \fn QString QStandardPaths::storageLocation(StandardLocation type)
+
+ Returns the default system directory where files of \a type belong, or an empty string
+ if the location cannot be determined.
+
+ \note The storage location returned can be a directory that does not exist; i.e., it
+ may need to be created by the system or the user.
+
+ \note On Symbian OS, ApplicationsLocation always point /sys/bin folder on the same drive
+ with executable. FontsLocation always points to folder on ROM drive. Symbian OS does not
+ have desktop concept, DesktopLocation returns same path as DocumentsLocation.
+ Rest of the standard locations point to folder on same drive with executable, except
+ that if executable is in ROM the folder from C drive is returned.
+*/
+
+/*!
+ \fn QString QStandardPaths::displayName(StandardLocation type)
+
+ Returns a localized display name for the given location \a type or
+ an empty QString if no relevant location can be found.
+*/
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_STANDARDPATHS
diff --git a/src/corelib/io/qstandardpaths.h b/src/corelib/io/qstandardpaths.h
new file mode 100644
index 0000000000..5b1bb826af
--- /dev/null
+++ b/src/corelib/io/qstandardpaths.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTANDARDPATHS_H
+#define QSTANDARDPATHS_H
+
+#include <QtCore/qstring.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Core)
+
+#ifndef QT_NO_STANDARDPATHS
+
+class QStringList;
+
+class Q_CORE_EXPORT QStandardPaths
+{
+public:
+ // Do not re-order, must match QDesktopServices
+ enum StandardLocation {
+ DesktopLocation,
+ DocumentsLocation,
+ FontsLocation,
+ ApplicationsLocation,
+ MusicLocation,
+ MoviesLocation,
+ PicturesLocation,
+ TempLocation,
+ HomeLocation,
+ DataLocation,
+ CacheLocation
+ };
+
+ static QString storageLocation(StandardLocation type);
+ static QString displayName(StandardLocation type);
+};
+
+#endif // QT_NO_STANDARDPATHS
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSTANDARDPATHS_H
diff --git a/src/corelib/io/qstandardpaths_mac.cpp b/src/corelib/io/qstandardpaths_mac.cpp
new file mode 100644
index 0000000000..b90cc7c6f2
--- /dev/null
+++ b/src/corelib/io/qstandardpaths_mac.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT_NO_DESKTOPSERVICES
+
+#include "qstandardpaths.h"
+#include <qdir.h>
+#include <private/qcore_mac_p.h>
+#include <qcoreapplication.h>
+
+#include <ApplicationServices/ApplicationServices.h>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ Translates a QStandardPaths::StandardLocation into the mac equivalent.
+*/
+OSType translateLocation(QStandardPaths::StandardLocation type)
+{
+ switch (type) {
+ case QStandardPaths::DesktopLocation:
+ return kDesktopFolderType;
+ case QStandardPaths::DocumentsLocation:
+ return kDocumentsFolderType;
+ case QStandardPaths::FontsLocation:
+ // There are at least two different font directories on the mac: /Library/Fonts and ~/Library/Fonts.
+ // To select a specific one we have to specify a different first parameter when calling FSFindFolder.
+ return kFontsFolderType;
+ case QStandardPaths::ApplicationsLocation:
+ return kApplicationsFolderType;
+ case QStandardPaths::MusicLocation:
+ return kMusicDocumentsFolderType;
+ case QStandardPaths::MoviesLocation:
+ return kMovieDocumentsFolderType;
+ case QStandardPaths::PicturesLocation:
+ return kPictureDocumentsFolderType;
+ case QStandardPaths::TempLocation:
+ return kTemporaryFolderType;
+ case QStandardPaths::DataLocation:
+ return kApplicationSupportFolderType;
+ case QStandardPaths::CacheLocation:
+ return kCachedDataFolderType;
+ default:
+ return kDesktopFolderType;
+ }
+}
+
+/*
+ Constructs a full unicode path from a FSRef.
+*/
+static QString getFullPath(const FSRef &ref)
+{
+ QByteArray ba(2048, 0);
+ if (FSRefMakePath(&ref, reinterpret_cast<UInt8 *>(ba.data()), ba.size()) == noErr)
+ return QString::fromUtf8(ba).normalized(QString::NormalizationForm_C);
+ return QString();
+}
+
+QString QStandardPaths::storageLocation(StandardLocation type)
+{
+ if (type == HomeLocation)
+ return QDir::homePath();
+
+ if (type == TempLocation)
+ return QDir::tempPath();
+
+ short domain = kOnAppropriateDisk;
+
+ if (type == DataLocation || type == CacheLocation)
+ domain = kUserDomain;
+
+ // http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
+ FSRef ref;
+ OSErr err = FSFindFolder(domain, translateLocation(type), false, &ref);
+ if (err)
+ return QString();
+
+ QString path = getFullPath(ref);
+
+ if (type == DataLocation || type == CacheLocation) {
+ if (QCoreApplication::organizationName().isEmpty() == false)
+ path += QLatin1Char('/') + QCoreApplication::organizationName();
+ if (QCoreApplication::applicationName().isEmpty() == false)
+ path += QLatin1Char('/') + QCoreApplication::applicationName();
+ }
+
+ return path;
+}
+
+QString QStandardPaths::displayName(StandardLocation type)
+{
+ if (QStandardPaths::HomeLocation == type)
+ return QCoreApplication::translate("QStandardPaths", "Home");
+
+ FSRef ref;
+ OSErr err = FSFindFolder(kOnAppropriateDisk, translateLocation(type), false, &ref);
+ if (err)
+ return QString();
+
+ QCFString displayName;
+ err = LSCopyDisplayNameForRef(&ref, &displayName);
+ if (err)
+ return QString();
+
+ return static_cast<QString>(displayName);
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DESKTOPSERVICES
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
new file mode 100644
index 0000000000..f0c50059a9
--- /dev/null
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstandardpaths.h"
+#include <qprocess.h>
+#include <qurl.h>
+#include <qdir.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qcoreapplication.h>
+#include <stdlib.h>
+
+#ifndef QT_NO_STANDARDPATHS
+
+QT_BEGIN_NAMESPACE
+
+QString QStandardPaths::storageLocation(StandardLocation type)
+{
+ if (type == QStandardPaths::HomeLocation)
+ return QDir::homePath();
+ if (type == QStandardPaths::TempLocation)
+ return QDir::tempPath();
+
+ // http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
+ if (type == QStandardPaths::CacheLocation) {
+ QString xdgCacheHome = QLatin1String(qgetenv("XDG_CACHE_HOME"));
+ if (xdgCacheHome.isEmpty())
+ xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
+ xdgCacheHome += QLatin1Char('/') + QCoreApplication::organizationName()
+ + QLatin1Char('/') + QCoreApplication::applicationName();
+ return xdgCacheHome;
+ }
+
+ if (type == QStandardPaths::DataLocation) {
+ QString xdgDataHome = QLatin1String(qgetenv("XDG_DATA_HOME"));
+ if (xdgDataHome.isEmpty())
+ xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
+ xdgDataHome += QLatin1String("/data/")
+ + QCoreApplication::organizationName() + QLatin1Char('/')
+ + QCoreApplication::applicationName();
+ return xdgDataHome;
+ }
+
+ // http://www.freedesktop.org/wiki/Software/xdg-user-dirs
+ QString xdgConfigHome = QLatin1String(qgetenv("XDG_CONFIG_HOME"));
+ if (xdgConfigHome.isEmpty())
+ xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
+ QFile file(xdgConfigHome + QLatin1String("/user-dirs.dirs"));
+ if (file.exists() && file.open(QIODevice::ReadOnly)) {
+ QHash<QString, QString> lines;
+ QTextStream stream(&file);
+ // Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop"
+ QRegExp exp(QLatin1String("^XDG_(.*)_DIR=(.*)$"));
+ while (!stream.atEnd()) {
+ QString line = stream.readLine();
+ if (exp.indexIn(line) != -1) {
+ const QStringList lst = exp.capturedTexts();
+ const QString key = lst.at(1);
+ QString value = lst.at(2);
+ if (value.length() > 2
+ && value.startsWith(QLatin1Char('\"'))
+ && value.endsWith(QLatin1Char('\"')))
+ value = value.mid(1, value.length() - 2);
+ // Store the key and value: "DESKTOP", "$HOME/Desktop"
+ lines[key] = value;
+ }
+ }
+
+ QString key;
+ switch (type) {
+ case DesktopLocation: key = QLatin1String("DESKTOP"); break;
+ case DocumentsLocation: key = QLatin1String("DOCUMENTS"); break;
+ case PicturesLocation: key = QLatin1String("PICTURES"); break;
+ case MusicLocation: key = QLatin1String("MUSIC"); break;
+ case MoviesLocation: key = QLatin1String("VIDEOS"); break;
+ default: break;
+ }
+ if (!key.isEmpty() && lines.contains(key)) {
+ QString value = lines[key];
+ // value can start with $HOME
+ if (value.startsWith(QLatin1String("$HOME")))
+ value = QDir::homePath() + value.mid(5);
+ return value;
+ }
+ }
+
+ QDir emptyDir;
+ QString path;
+ switch (type) {
+ case DesktopLocation:
+ path = QDir::homePath() + QLatin1String("/Desktop");
+ break;
+ case DocumentsLocation:
+ path = QDir::homePath() + QLatin1String("/Documents");
+ break;
+ case PicturesLocation:
+ path = QDir::homePath() + QLatin1String("/Pictures");
+ break;
+
+ case FontsLocation:
+ path = QDir::homePath() + QLatin1String("/.fonts");
+ break;
+
+ case MusicLocation:
+ path = QDir::homePath() + QLatin1String("/Music");
+ break;
+
+ case MoviesLocation:
+ path = QDir::homePath() + QLatin1String("/Videos");
+ break;
+
+ case ApplicationsLocation:
+ default:
+ break;
+ }
+
+ return path;
+}
+
+QString QStandardPaths::displayName(StandardLocation type)
+{
+ Q_UNUSED(type);
+ return QString();
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_STANDARDPATHS
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
new file mode 100644
index 0000000000..7d7fbd0857
--- /dev/null
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -0,0 +1,167 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstandardpaths.h"
+
+#include <qsettings.h>
+#include <qdir.h>
+#include <private/qsystemlibrary_p.h>
+#include <qurl.h>
+#include <qstringlist.h>
+#include <qprocess.h>
+#include <qtemporaryfile.h>
+#include <qcoreapplication.h>
+
+#include <qt_windows.h>
+#include <shlobj.h>
+#if !defined(Q_OS_WINCE)
+# include <intshcut.h>
+#else
+# include <qguifunctions_wince.h>
+# if !defined(STANDARDSHELL_UI_MODEL)
+# include <winx.h>
+# endif
+#endif
+
+#ifndef CSIDL_MYMUSIC
+#define CSIDL_MYMUSIC 13
+#define CSIDL_MYVIDEO 14
+#endif
+
+#ifndef QT_NO_STANDARDPATHS
+
+QT_BEGIN_NAMESPACE
+
+QString QStandardPaths::storageLocation(StandardLocation type)
+{
+ QString result;
+
+#ifndef Q_OS_WINCE
+ QSystemLibrary library(QLatin1String("shell32"));
+#else
+ QSystemLibrary library(QLatin1String("coredll"));
+#endif // Q_OS_WINCE
+ typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL);
+ static GetSpecialFolderPath SHGetSpecialFolderPath =
+ (GetSpecialFolderPath)library.resolve("SHGetSpecialFolderPathW");
+ if (!SHGetSpecialFolderPath)
+ return QString();
+
+ wchar_t path[MAX_PATH];
+
+ switch (type) {
+ case DataLocation:
+#if defined Q_OS_WINCE
+ if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE))
+#else
+ if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
+#endif
+ result = QString::fromWCharArray(path);
+ if (!QCoreApplication::organizationName().isEmpty())
+ result = result + QLatin1String("\\") + QCoreApplication::organizationName();
+ if (!QCoreApplication::applicationName().isEmpty())
+ result = result + QLatin1String("\\") + QCoreApplication::applicationName();
+ break;
+
+ case DesktopLocation:
+ if (SHGetSpecialFolderPath(0, path, CSIDL_DESKTOPDIRECTORY, FALSE))
+ result = QString::fromWCharArray(path);
+ break;
+
+ case DocumentsLocation:
+ if (SHGetSpecialFolderPath(0, path, CSIDL_PERSONAL, FALSE))
+ result = QString::fromWCharArray(path);
+ break;
+
+ case FontsLocation:
+ if (SHGetSpecialFolderPath(0, path, CSIDL_FONTS, FALSE))
+ result = QString::fromWCharArray(path);
+ break;
+
+ case ApplicationsLocation:
+ if (SHGetSpecialFolderPath(0, path, CSIDL_PROGRAMS, FALSE))
+ result = QString::fromWCharArray(path);
+ break;
+
+ case MusicLocation:
+ if (SHGetSpecialFolderPath(0, path, CSIDL_MYMUSIC, FALSE))
+ result = QString::fromWCharArray(path);
+ break;
+
+ case MoviesLocation:
+ if (SHGetSpecialFolderPath(0, path, CSIDL_MYVIDEO, FALSE))
+ result = QString::fromWCharArray(path);
+ break;
+
+ case PicturesLocation:
+ if (SHGetSpecialFolderPath(0, path, CSIDL_MYPICTURES, FALSE))
+ result = QString::fromWCharArray(path);
+ break;
+
+ case CacheLocation:
+ // 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 storageLocation(DataLocation) + QLatin1String("\\cache");
+
+ case QStandardPaths::HomeLocation:
+ result = QDir::homePath();
+ break;
+
+ case QStandardPaths::TempLocation:
+ result = QDir::tempPath();
+ break;
+
+ default:
+ break;
+ }
+ return result;
+}
+
+QString QStandardPaths::displayName(StandardLocation type)
+{
+ Q_UNUSED(type);
+ return QString();
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_STANDARDPATHS