mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-16 00:08:48 +02:00
Merge pull request #13459 from zfox23/MS16113_hifikeyPath
Fix MS16113: Use alternate method for creating backup instructions
This commit is contained in:
commit
56b3c125c5
1 changed files with 21 additions and 12 deletions
|
@ -127,31 +127,40 @@ EC_KEY* readKeys(const char* filename) {
|
||||||
bool Wallet::writeBackupInstructions() {
|
bool Wallet::writeBackupInstructions() {
|
||||||
QString inputFilename(PathUtils::resourcesPath() + "html/commerce/backup_instructions.html");
|
QString inputFilename(PathUtils::resourcesPath() + "html/commerce/backup_instructions.html");
|
||||||
QString outputFilename = PathUtils::getAppDataFilePath(INSTRUCTIONS_FILE);
|
QString outputFilename = PathUtils::getAppDataFilePath(INSTRUCTIONS_FILE);
|
||||||
|
QFile inputFile(inputFilename);
|
||||||
QFile outputFile(outputFilename);
|
QFile outputFile(outputFilename);
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
|
|
||||||
if (QFile::exists(outputFilename) || getKeyFilePath() == "")
|
if (getKeyFilePath() == "")
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QFile::copy(inputFilename, outputFilename);
|
|
||||||
|
|
||||||
if (QFile::exists(outputFilename) && outputFile.open(QIODevice::ReadWrite)) {
|
if (QFile::exists(inputFilename) && inputFile.open(QIODevice::ReadOnly)) {
|
||||||
|
if (outputFile.open(QIODevice::ReadWrite)) {
|
||||||
|
// Read the data from the original file, then close it
|
||||||
|
QByteArray fileData = inputFile.readAll();
|
||||||
|
inputFile.close();
|
||||||
|
|
||||||
QByteArray fileData = outputFile.readAll();
|
// Translate the data from the original file into a QString
|
||||||
QString text(fileData);
|
QString text(fileData);
|
||||||
|
|
||||||
text.replace(QString("HIFIKEY_PATH_REPLACEME"), keyFilePath());
|
// Replace the necessary string
|
||||||
|
text.replace(QString("HIFIKEY_PATH_REPLACEME"), keyFilePath());
|
||||||
|
|
||||||
outputFile.seek(0); // go to the beginning of the file
|
// Write the new text back to the file
|
||||||
outputFile.write(text.toUtf8()); // write the new text back to the file
|
outputFile.write(text.toUtf8());
|
||||||
|
|
||||||
outputFile.close(); // close the file handle.
|
// Close the output file
|
||||||
|
outputFile.close();
|
||||||
|
|
||||||
retval = true;
|
retval = true;
|
||||||
qCDebug(commerce) << "wrote html file successfully";
|
qCDebug(commerce) << "wrote html file successfully";
|
||||||
|
} else {
|
||||||
|
qCDebug(commerce) << "failed to open output html file" << outputFilename;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
qCDebug(commerce) << "failed to open output html file" << outputFilename;
|
qCDebug(commerce) << "failed to open input html file" << inputFilename;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue