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)")
189 QDir prefixDir = qApp->applicationDirPath();
197 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Relative PREFIX! (%1), appDir=%2")
202 LOG(VB_GENERAL, LOG_ERR,
203 QString(
"Relative PREFIX does not resolve, using %1")
204 .arg(prefixDir.canonicalPath()));
216 confdir = QDir::homePath() +
"/.mythtv";
222 #if defined(Q_OS_ANDROID)
235 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Using configuration directory = %1")
239 LOG(VB_GENERAL, LOG_DEBUG,
"sharedir = "+
sharedir );
240 LOG(VB_GENERAL, LOG_DEBUG,
"libdir = "+
libdir );
241 LOG(VB_GENERAL, LOG_DEBUG,
"themedir = "+
themedir );
245 LOG(VB_GENERAL, LOG_DEBUG,
"confdir = "+
confdir );
246 LOG(VB_GENERAL, LOG_DEBUG,
"cachedir = "+
cachedir );
298 #elif defined(_WIN32)
303 #elif defined(Q_OS_ANDROID)
332 return "mythfrontend_*.qm";
338 +
"mythfrontend_" + translation.toLower() +
".qm";