5#if QT_VERSION >= QT_VERSION_CHECK(6,5,0)
6#include <QtEnvironmentVariables>
7#include <QtSystemDetection>
10#include <QCoreApplication>
14#include <QStandardPaths>
15#elif defined(Q_OS_WINDOWS)
16#include <QStandardPaths>
38 confdir = qEnvironmentVariable(
"MYTHCONFDIR" );
42 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Read conf dir = %1").arg(
confdir));
43 confdir.replace(
"$HOME", QDir::homePath());
49 installprefix = QDir{QCoreApplication::applicationDirPath()}.absolutePath();
56 QDir sDir(qEnvironmentVariable(
"ProgramData") +
"/mythtv/");
58 sharedir = sDir.canonicalPath() +
"/";
66 confdir = qEnvironmentVariable(
"LOCALAPPDATA" ) +
"/mythtv";
78 qApp->setOrganizationName(
"mythtv" );
80 QStringList lstPaths = QStandardPaths::standardLocations(
81 QStandardPaths::AppDataLocation);
85 QString sAppName = qApp->applicationName();
86 if (!lstPaths.isEmpty())
88 for (
auto &path : lstPaths)
90 if (path.endsWith(sAppName))
91 path = path.left(path.length() - sAppName.length());
92 LOG(VB_GENERAL, LOG_DEBUG, QString(
"app data location: %1 (%2)")
93 .arg(path).arg(QDir(path).
exists() ?
"exists" :
"doesn't exist"));
102 lstPaths = QStandardPaths::standardLocations(
103 QStandardPaths::AppConfigLocation);
104 if (!lstPaths.isEmpty())
106 for (
auto &path : lstPaths)
108 if (path.endsWith(sAppName))
109 path = path.left(path.length() - sAppName.length());
110 LOG(VB_GENERAL, LOG_DEBUG, QString(
"app config location: %1 (%2)")
111 .arg(path).arg(QDir(path).
exists() ?
"exists" :
"doesn't exist"));
119 if (
confdir.endsWith( sAppName ))
130#elif defined(Q_OS_ANDROID)
132 installprefix = QDir{QCoreApplication::applicationDirPath()}.absolutePath();
133 QString extdir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +
"/Mythtv";
134 if (!QDir(extdir).
exists())
135 QDir(extdir).mkdir(
".");
138 confdir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
142 QStringList appLocs = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
143 uintmax_t maxFreeSpace = 0;
144 constexpr uintmax_t k_unknown_size {
static_cast<std::uintmax_t
>(-1)};
145 for(
const auto & s : appLocs)
147 std::filesystem::space_info space_info = std::filesystem::space(s.toStdString());
149 (space_info.capacity == 0
150 || space_info.free == 0
151 || space_info.available == 0
153 (space_info.capacity == k_unknown_size
154 || space_info.free == k_unknown_size
155 || space_info.available == k_unknown_size
157 ) && space_info.available >= maxFreeSpace
160 maxFreeSpace = space_info.available;
163 LOG(VB_GENERAL, LOG_NOTICE, QString(
" appdatadir = %1 (%2, %3, %4)")
165 .arg(space_info.available)
166 .arg(space_info.free)
167 .arg(space_info.capacity)
170 QStringList cacheLocs = QStandardPaths::standardLocations(QStandardPaths::CacheLocation);
172 for(
const auto & s : cacheLocs)
174 std::filesystem::space_info space_info = std::filesystem::space(s.toStdString());
176 (space_info.capacity == 0
177 || space_info.free == 0
178 || space_info.available == 0
180 (space_info.capacity == k_unknown_size
181 || space_info.free == k_unknown_size
182 || space_info.available == k_unknown_size
184 ) && space_info.available >= maxFreeSpace
187 maxFreeSpace = space_info.available;
190 LOG(VB_GENERAL, LOG_NOTICE, QString(
" cachedir = %1 (%2, %3, %4)")
192 .arg(space_info.available)
193 .arg(space_info.free)
194 .arg(space_info.capacity)
207 QDir installdir {QCoreApplication::applicationDirPath()};
225 QDir prefixDir {QCoreApplication::applicationDirPath()};
226 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Relative PREFIX! (%1), appDir=%2")
231 LOG(VB_GENERAL, LOG_ERR,
232 QString(
"Relative PREFIX does not resolve, using %1")
233 .arg(prefixDir.canonicalPath()));
245 confdir = QDir::homePath() +
"/.mythtv";
262 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Using configuration directory = %1")
266 LOG(VB_GENERAL, LOG_DEBUG,
"sharedir = "+
sharedir );
267 LOG(VB_GENERAL, LOG_DEBUG,
"libdir = "+
libdir );
268 LOG(VB_GENERAL, LOG_DEBUG,
"themedir = "+
themedir );
271 LOG(VB_GENERAL, LOG_DEBUG,
"confdir = "+
confdir );
272 LOG(VB_GENERAL, LOG_DEBUG,
"cachedir = "+
cachedir );
321#elif defined(Q_OS_WINDOWS)
324#elif defined(Q_OS_ANDROID)
344 return "mythfrontend_*.qm";
350 +
"mythfrontend_" + translation.toLower() +
".qm";
QString GetInstallPrefix(void)
QString GetPluginsNameFilter(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 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
QString GetThemeBaseCacheDir(void)
Returns the base directory where all theme related files should be cached.
QString FindTranslation(const QString &translation)
static QString remotecachedir
static QString thumbnaildir
static QString pluginsdir
#define LOG(_MASK_, _LEVEL_, _QSTRING_)