QStandardPaths: add GenericCacheLocation.
Much like DataLocation = GenericDataLocation + domain + appname, this makes CacheLocation = GenericCacheLocation + domain + appname. This way a framework library can have an application-independent cache (like ksycoca). Change-Id: I6a8c47ff85b7d5c68b594cc8b071a752d96b029d Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
bff6cf7b5b
commit
053676a80e
@ -83,6 +83,8 @@ QT_BEGIN_NAMESPACE
|
||||
returned for GenericDataLocation.
|
||||
\value CacheLocation Returns a directory location where user-specific
|
||||
non-essential (cached) data should be written.
|
||||
\value GenericCacheLocation Returns a directory location where user-specific
|
||||
non-essential (cached) data, shared across applications, should be written.
|
||||
\value GenericDataLocation Returns a directory location where persistent
|
||||
data shared across applications can be stored.
|
||||
\value RuntimeLocation Returns a directory location where runtime communication
|
||||
|
@ -73,7 +73,8 @@ public:
|
||||
GenericDataLocation,
|
||||
RuntimeLocation,
|
||||
ConfigLocation,
|
||||
DownloadLocation
|
||||
DownloadLocation,
|
||||
GenericCacheLocation
|
||||
};
|
||||
|
||||
static QString writableLocation(StandardLocation type);
|
||||
|
@ -82,6 +82,7 @@ OSType translateLocation(QStandardPaths::StandardLocation type)
|
||||
case QStandardPaths::RuntimeLocation:
|
||||
case QStandardPaths::DataLocation:
|
||||
return kApplicationSupportFolderType;
|
||||
case QStandardPaths::GenericCacheLocation:
|
||||
case QStandardPaths::CacheLocation:
|
||||
return kCachedDataFolderType;
|
||||
default:
|
||||
@ -128,6 +129,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
|
||||
return QDir::tempPath();
|
||||
case GenericDataLocation:
|
||||
case DataLocation:
|
||||
case GenericCacheLocation:
|
||||
case CacheLocation:
|
||||
case RuntimeLocation:
|
||||
return macLocation(type, kUserDomain);
|
||||
@ -140,7 +142,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
|
||||
{
|
||||
QStringList dirs;
|
||||
|
||||
if (type == GenericDataLocation || type == DataLocation || type == CacheLocation) {
|
||||
if (type == GenericDataLocation || type == DataLocation || type == GenericCacheLocation || type == CacheLocation) {
|
||||
const QString path = macLocation(type, kOnAppropriateDisk);
|
||||
if (!path.isEmpty())
|
||||
dirs.append(path);
|
||||
|
@ -62,15 +62,18 @@ QString QStandardPaths::writableLocation(StandardLocation type)
|
||||
case TempLocation:
|
||||
return QDir::tempPath();
|
||||
case CacheLocation:
|
||||
case GenericCacheLocation:
|
||||
{
|
||||
// http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
|
||||
QString xdgCacheHome = QFile::decodeName(qgetenv("XDG_CACHE_HOME"));
|
||||
if (xdgCacheHome.isEmpty())
|
||||
xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
|
||||
if (type == QStandardPaths::CacheLocation) {
|
||||
if (!QCoreApplication::organizationName().isEmpty())
|
||||
xdgCacheHome += QLatin1Char('/') + QCoreApplication::organizationName();
|
||||
if (!QCoreApplication::applicationName().isEmpty())
|
||||
xdgCacheHome += QLatin1Char('/') + QCoreApplication::applicationName();
|
||||
}
|
||||
return xdgCacheHome;
|
||||
}
|
||||
case DataLocation:
|
||||
|
@ -160,6 +160,9 @@ QString QStandardPaths::writableLocation(StandardLocation type)
|
||||
// cache directory located in their AppData directory
|
||||
return writableLocation(DataLocation) + QLatin1String("\\cache");
|
||||
|
||||
case GenericCacheLocation:
|
||||
return writableLocation(GenericDataLocation) + QLatin1String("\\cache");
|
||||
|
||||
case RuntimeLocation:
|
||||
case HomeLocation:
|
||||
result = QDir::homePath();
|
||||
|
Loading…
Reference in New Issue
Block a user