6#include <QCoreApplication>
8#if defined(Q_OS_ANDROID)
9#include <QStandardPaths>
10#include <sys/statfs.h>
11#elif defined(Q_OS_WIN)
12#include <QStandardPaths>
35 confdir = qgetenv(
"MYTHCONFDIR" );
39 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Read conf dir = %1").arg(
confdir));
40 confdir.replace(
"$HOME", QDir::homePath());
54 QDir sDir(qgetenv(
"ProgramData") +
"/mythtv/");
56 sharedir = sDir.canonicalPath() +
"/";
64 confdir = qgetenv(
"LOCALAPPDATA" ) +
"/mythtv";
76 qApp->setOrganizationName(
"mythtv" );
78 QStringList lstPaths = QStandardPaths::standardLocations(
79 QStandardPaths::AppDataLocation);
83 QString sAppName = qApp->applicationName();
84 if (!lstPaths.isEmpty())
86 for (
auto &path : lstPaths)
88 if (path.endsWith(sAppName))
89 path = path.left(path.length() - sAppName.length());
90 LOG(VB_GENERAL, LOG_DEBUG, QString(
"app data location: %1 (%2)")
91 .arg(path).arg(QDir(path).
exists() ?
"exists" :
"doesn't exist"));
100 lstPaths = QStandardPaths::standardLocations(
101 QStandardPaths::AppConfigLocation);
102 if (!lstPaths.isEmpty())
104 for (
auto &path : lstPaths)
106 if (path.endsWith(sAppName))
107 path = path.left(path.length() - sAppName.length());
108 LOG(VB_GENERAL, LOG_DEBUG, QString(
"app config location: %1 (%2)")
109 .arg(path).arg(QDir(path).
exists() ?
"exists" :
"doesn't exist"));
117 if (
confdir.endsWith( sAppName ))
128#elif defined(Q_OS_ANDROID)
132 QString extdir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +
"/Mythtv";
133 if (!QDir(extdir).
exists())
134 QDir(extdir).mkdir(
".");
137 confdir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
141 QStringList appLocs = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
142 uint64_t maxFreeSpace = 0;
143 for(
auto s : appLocs)
146 memset(&statFs, 0,
sizeof(statFs));
147 int ret =
statfs(s.toLocal8Bit().data(), &statFs);
148 if (ret == 0 && statFs.
f_bavail >= maxFreeSpace)
153 LOG(VB_GENERAL, LOG_NOTICE, QString(
" appdatadir = %1 (%2, %3, %4)")
159 QStringList cacheLocs = QStandardPaths::standardLocations(QStandardPaths::CacheLocation);
161 for(
auto s : cacheLocs)
164 memset(&statFs, 0,
sizeof(statFs));
165 int ret =
statfs(s.toLocal8Bit().data(), &statFs);
166 if (ret == 0 && statFs.
f_bavail >= maxFreeSpace)
171 LOG(VB_GENERAL, LOG_NOTICE, QString(
" cachedir = %1 (%2, %3, %4)")
188 #if defined(Q_OS_DARWIN)
196 QDir prefixDir = qApp->applicationDirPath();
204 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Relative PREFIX! (%1), appDir=%2")
209 LOG(VB_GENERAL, LOG_ERR,
210 QString(
"Relative PREFIX does not resolve, using %1")
211 .arg(prefixDir.canonicalPath()));
223 confdir = QDir::homePath() +
"/.mythtv";
229#if defined(Q_OS_ANDROID)
242 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Using configuration directory = %1")
246 LOG(VB_GENERAL, LOG_DEBUG,
"sharedir = "+
sharedir );
247 LOG(VB_GENERAL, LOG_DEBUG,
"libdir = "+
libdir );
248 LOG(VB_GENERAL, LOG_DEBUG,
"themedir = "+
themedir );
252 LOG(VB_GENERAL, LOG_DEBUG,
"confdir = "+
confdir );
253 LOG(VB_GENERAL, LOG_DEBUG,
"cachedir = "+
cachedir );
310#elif defined(Q_OS_ANDROID)
339 return "mythfrontend_*.qm";
345 +
"mythfrontend_" + translation.toLower() +
".qm";
int statfs(const char *path, struct statfs *buffer)
QString GetInstallPrefix(void)
QString GetPluginsNameFilter(void)
QString GetFiltersDir(void)
QString FindPluginName(const QString &plugname)
static QString translationsdir
QString GetPluginsDir(void)
QString GetTranslationsDir(void)
static QString themebasecachedir
QString GetRemoteCacheDir(void)
Returns the directory for all files cached from the backend.
QString GetFiltersNameFilter(void)
QString GetShareDir(void)
static QString installprefix
QString GetLibraryDir(void)
QString GetFontsDir(void)
QString GetAppBinDir(void)
QString GetThemesParentDir(void)
QString GetThumbnailDir(void)
Returns the directory where all non-theme thumbnail files should be cached.
void InitializeMythDirs(void)
QString GetCacheDir(void)
Returns the base directory for all cached files.
static const QString kPluginLibPrefix
QString GetTranslationsNameFilter(void)
static const QString kPluginLibSuffix
static const QString kFilterLibPrefix
QString GetThemeBaseCacheDir(void)
Returns the base directory where all theme related files should be cached.
QString FindTranslation(const QString &translation)
static QString filtersdir
static const QString kFilterLibSuffix
static QString remotecachedir
static QString thumbnaildir
static QString pluginsdir
#define LOG(_MASK_, _LEVEL_, _QSTRING_)