This commit is contained in:
Andrei Yankovich 2020-01-10 16:02:07 +03:00
parent b4453c2c00
commit 9ecced008e
4 changed files with 33 additions and 24 deletions

View File

@ -21,11 +21,10 @@
bool ConfigParser::parseParams() {
auto path = QuasarAppUtils::Params::getStrArg("confFile");
bool createFile = !(path.isEmpty() || QFile::exists(path));
if (path.isEmpty()) {
path = QFileInfo("./").absoluteFilePath();
bool createFile = !QFile::exists(path);
if (QFile::exists(path)) {
loadFromFile(path);
}
loadFromFile(path);
switch (DeployCore::getMode()) {
case RunMode::Info: {
@ -132,17 +131,8 @@ void ConfigParser::readKey(const QString& key, const QJsonObject& obj,
QString val = i.toString();
if (!val.isEmpty()) {
if (PathUtils::isPath(val)) {
QString path;
if (PathUtils::isAbsalutPath(val)) {
path = QFileInfo(val).absoluteFilePath();
} else {
path = QFileInfo(confFileDir + '/' + val).absoluteFilePath();
}
list.push_back(path);
if (PathUtils::isReleativePath(val)) {
list.push_back(QFileInfo(confFileDir + '/' + val).absoluteFilePath());
} else {
list.push_back(val);
}
@ -155,16 +145,12 @@ void ConfigParser::readKey(const QString& key, const QJsonObject& obj,
QString val = obj[key].toString();
if (!val.isEmpty()) {
if (PathUtils::isPath(val)) {
if (PathUtils::isAbsalutPath(val)) {
val = QFileInfo(val).absoluteFilePath();
} else {
val = QFileInfo(confFileDir + '/' + val).absoluteFilePath();
}
if (PathUtils::isReleativePath(val)) {
QuasarAppUtils::Params::setArg(key, QFileInfo(confFileDir + '/' + val).absoluteFilePath());
} else {
QuasarAppUtils::Params::setArg(key, val);
}
QuasarAppUtils::Params::setArg(key, val);
} else {
auto value = obj[key].toBool(true);
QuasarAppUtils::Params::setEnable(key, value);

View File

@ -7,6 +7,7 @@
#include "pathutils.h"
#include <QDir>
#include <QFileInfo>
PathUtils::PathUtils()
@ -66,7 +67,20 @@ QString PathUtils::getRelativeLink(QString from, QString to) {
// TODO ignore labels may be mistaken for a path, which will lead to improper eating
bool PathUtils::isPath(const QString &path) {
return path.contains('/') || path.contains('\\') || path == ".";
QFileInfo info(path);
return info.exists();
// return path.contains('/') || path.contains('\\') || path == ".";
}
bool PathUtils::isReleativePath(const QString &path) {
QString temp = QDir::fromNativeSeparators(path);
if (temp.size() == 1) {
return path[0] == '.';
} else if (temp.size() > 1) {
return path[0] == '.' && path[1] == '/';
}
return false;
}
QChar PathUtils::getDrive(QString path) {

View File

@ -63,6 +63,13 @@ public:
*/
static bool isPath(const QString &path);
/**
* @brief isPath
* @param path
* @return return true if imput value is Releative path
*/
static bool isReleativePath(const QString &path);
/**
* @brief getDrive
* @param path

View File

@ -1177,6 +1177,8 @@ void deploytest::testConfFile() {
QFile::remove(TestBinDir + "/../folder/For/Testing/Deploy/File/TestConf.json");
// Test generar string in confFile
comapareTree = Modules::qtLibs();
comapareTree = Modules::ignoreFilter(comapareTree, "/plugins/p");