17#include <QStandardPaths>
26 std::streampos initialPosition = file.tellg();
30 while (c != -1 && c !=
'\n')
38 file.seekg(initialPosition, std::ios_base::beg);
45 qint64 initialPosition = file.pos();
49 while (!file.atEnd() && c !=
'\n')
56 file.seek(initialPosition);
66 for (
const auto& path: source)
68 if ( !path.isEmpty() && !target.contains(path) && QDir(path).exists() )
77 return QString::fromUtf8(qgetenv((name.toUpper()).toStdString().c_str()).constData());
82 QString dataHome = QString::fromUtf8(qgetenv(
"XDG_DATA_HOME"));
83 if (dataHome.isEmpty())
85 dataHome = QString::fromUtf8(qgetenv(
"HOME"));
86 if (!dataHome.isEmpty())
88 dataHome +=
"/.local/share/";
97 if ( QDir( path ).exists() )
109 const QString& project,
110 const QString& path_prefix,
111 const QString& path_postfix = QString(
""))
114 getEnvVar(project +
"_DIST") + path_prefix + project + path_postfix,
115 QString::fromUtf8(
"/usr/") + path_prefix + project + path_postfix);
119 const QString& project,
120 const QString& env_postfix,
121 const QString& path_prefix,
122 const QString& path_postfix = QString(
"")
126 QString var =
getEnvVar(project + env_postfix);
127 if ( !var.isEmpty() )
134 if ( dirs.isEmpty() )
142 const QStringList& paths)
145 QStringList configDirs;
151 if (projects.empty())
153 QString var =
getEnvVar(QString::fromStdString(
"lima") +
"_CONF");
154 if ( !var.isEmpty() )
162 for (
const auto& project: projects)
164 QString var =
getEnvVar(project.toUpper() +
"_CONF");
165 if ( !var.isEmpty() )
176 if ( configDirs.isEmpty() )
178 for (
const auto& project: projects)
184 QString var =
getEnvVar(QString::fromStdString(
"LIMA_SHOW_CONFIG_PATH"));
185 if ( !var.isEmpty() )
187 qDebug() <<
"LIMA Configuration directories list built is:" << configDirs;
194 const QStringList& paths)
197 QStringList resourcesDirs;
202 for (
const auto& project: projects)
205 "/share/apps/",
"/resources");
210 QString var =
getEnvVar(QString::fromStdString(
"LIMA_SHOW_CONFIG_PATH"));
211 if ( !var.isEmpty() )
213 qDebug() <<
"LIMA Resources directories list built is:" << resourcesDirs;
216 LINFO <<
"LIMA Resources directories list built is:" << resourcesDirs;
217 return resourcesDirs;
220QString
findFileInPaths(
const QString& paths,
const QString& fileName,
const QChar& separator)
222 auto pathsList = paths.split(separator);
223 auto filesList =fileName.split(separator);
224 for (
const auto& path: pathsList)
226 for (
const auto& file: filesList)
228 if (QFileInfo::exists(path +
"/" + file))
233 LDEBUG <<
"File found:" << path +
"/" + file;
236 return path +
"/" + file;
241 LINFO <<
"findFileInPaths no '" << fileName <<
"' found in '" << paths
242 <<
"' separated by '" << separator <<
"'";
#define FILESREPORTLOGINIT
#define LIMA_PATH_SEPARATOR
void buildDirectoriesListForProject(QStringList &target, const QString &project, const QString &env_postfix, const QString &path_prefix, const QString &path_postfix=QString(""))
void appendFirstOrSecondForProject(QStringList &target, const QString &project, const QString &path_prefix, const QString &path_postfix=QString(""))
QString getEnvVar(const QString &name)
QStringList buildResourcesDirectoriesList(const QStringList &projects, const QStringList &paths)
Build a list of resources directories from a list of project names and a list of paths.
void appendFirstOrSecond(QStringList &target, const QString &path, const QString &alt_path)
uint64_t countLines(std::istream &file)
Count the number of lines in the given file from the current position.
void appendNonEmptyDirs(QStringList &target, const QStringList &source)
QString findFileInPaths(const QString &paths, const QString &fileName, const QChar &separator)
Find the given file in the given paths.
QStringList buildConfigurationDirectoriesList(const QStringList &projects, const QStringList &paths)
Build a list of configuration directories from a list of project names and a list of paths.