QtDeployer/source/CPP/utils.cpp

46 lines
992 B
C++
Raw Normal View History

2018-06-10 14:44:36 +03:00
#include "utils.h"
#include <QFile>
#include <QFileInfo>
QString Utils::getVersion(){
2018-06-10 21:00:46 +03:00
QFileInfo f(":/snapcraft/snapcraft");
2018-06-10 14:44:36 +03:00
QFile file(f.absoluteFilePath());
if(file.open(QIODevice::ReadOnly)){
QString yamlFile = file.readAll();
file.close();
yamlFile.replace(" ", "");
yamlFile.replace("'", "");
int tempIndex = yamlFile.indexOf(QRegExp("version:"));
if(tempIndex < 0){
return "error in yaml version";
}
int beginTarget = tempIndex + 8;
tempIndex = yamlFile.indexOf("\n", beginTarget);
int longTraget = -1;
if(tempIndex >= 0){
longTraget = tempIndex - beginTarget;
}
return yamlFile.mid(beginTarget, longTraget);
}
return file.errorString();
}
2018-06-18 02:43:52 +03:00
/** @todo add get description method */
QString Utils::getDescription(){
return "";
}
/** @todo add get Publicher method */
QString Utils::getPublicher(){
return "QtDeployer";
}