mirror of
https://github.com/QuasarApp/QtDeployer.git
synced 2025-04-28 14:34:35 +00:00
36 lines
807 B
C++
36 lines
807 B
C++
#include "utils.h"
|
|
#include <QFile>
|
|
#include <QFileInfo>
|
|
|
|
|
|
QString Utils::getVersion(){
|
|
|
|
QFileInfo f("./../snap/snapcraft.yaml");
|
|
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();
|
|
}
|