|
@@ -77,16 +77,28 @@ QString ADCLicenseServ::readLicense()
|
|
QString filePath = "./license";
|
|
QString filePath = "./license";
|
|
|
|
|
|
QFile file(filePath);
|
|
QFile file(filePath);
|
|
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
|
|
- qDebug() << "Failed to open file.";
|
|
|
|
- return "1";
|
|
|
|
|
|
+ if (!QFile::exists(filePath)){
|
|
|
|
+ if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
|
|
+ QTextStream out(&file);
|
|
|
|
+ out << " " << endl;
|
|
|
|
+ file.close();
|
|
|
|
+ qDebug() << "File created and written successfully.";
|
|
|
|
+ return "0";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
|
|
+ qDebug() << "Failed to open file.";
|
|
|
|
+ return "1";
|
|
|
|
+ }
|
|
|
|
+ QTextStream in(&file);
|
|
|
|
+
|
|
|
|
+ QString fileContent = in.readAll();
|
|
|
|
+ fileContent=fileContent.remove(QChar('\n'));
|
|
|
|
+ file.close();
|
|
|
|
+ return fileContent;
|
|
}
|
|
}
|
|
- QTextStream in(&file);
|
|
|
|
|
|
|
|
- QString fileContent = in.readAll();
|
|
|
|
- fileContent=fileContent.remove(QChar('\n'));
|
|
|
|
- file.close();
|
|
|
|
- return fileContent;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void ADCLicenseServ::creatMachFile(const QString &str)
|
|
void ADCLicenseServ::creatMachFile(const QString &str)
|