Hi, > > What are the pros and cons of using QStandardPaths as opposed to XDG > Environmental Variables? >
If you look into the unix implementation of the class QStandardPaths, you find
something like
QString QStandardPaths::writableLocation(StandardLocation type)
{
switch (type) {
case HomeLocation:
return QDir::homePath();
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 (isTestModeEnabled())
xdgCacheHome = QDir::homePath() + QLatin1String("/.qttest/cache");
if (xdgCacheHome.isEmpty())
xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
if (type == QStandardPaths::CacheLocation)
appendOrganizationAndApp(xdgCacheHome);
return xdgCacheHome;
}
case DataLocation:
case GenericDataLocation:
{
QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME"));
if (isTestModeEnabled())
xdgDataHome = QDir::homePath() + QLatin1String("/.qttest/share");
if (xdgDataHome.isEmpty())
xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
if (type == QStandardPaths::DataLocation)
appendOrganizationAndApp(xdgDataHome);
return xdgDataHome;
}
case ConfigLocation:
{
// http://standards.freedesktop.org/basedir-spec/latest/
QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME"));
if (isTestModeEnabled())
xdgConfigHome = QDir::homePath() + QLatin1String("/.qttest/config");
if (xdgConfigHome.isEmpty())
xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
return xdgConfigHome;
}
So using QStandardPaths is
* convenience and brings you
* OS independance, because they (Qt) tend to choose the right position.
BR.
Sven
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ SailfishOS.org Devel mailing list
