mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-23 11:37:05 -04:00
Implement external patches.txt path for UEFIPatch
This commit is contained in:
parent
f383646033
commit
66c9d4a2cf
3 changed files with 14 additions and 9 deletions
|
@ -25,15 +25,15 @@ UEFIPatch::~UEFIPatch()
|
||||||
delete ffsEngine;
|
delete ffsEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT8 UEFIPatch::patchFromFile(QString path)
|
UINT8 UEFIPatch::patchFromFile(QString path, QString patches)
|
||||||
{
|
{
|
||||||
QFileInfo patchInfo = QFileInfo("patches.txt");
|
QFileInfo patchInfo = QFileInfo(patches);
|
||||||
|
|
||||||
if (!patchInfo.exists())
|
if (!patchInfo.exists())
|
||||||
return ERR_INVALID_FILE;
|
return ERR_INVALID_FILE;
|
||||||
|
|
||||||
QFile file;
|
QFile file;
|
||||||
file.setFileName("patches.txt");
|
file.setFileName(patches);
|
||||||
|
|
||||||
if (!file.open(QFile::ReadOnly | QFile::Text))
|
if (!file.open(QFile::ReadOnly | QFile::Text))
|
||||||
return ERR_INVALID_FILE;
|
return ERR_INVALID_FILE;
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
explicit UEFIPatch(QObject *parent = 0);
|
explicit UEFIPatch(QObject *parent = 0);
|
||||||
~UEFIPatch();
|
~UEFIPatch();
|
||||||
|
|
||||||
UINT8 patchFromFile(QString path);
|
UINT8 patchFromFile(QString path, QString patches);
|
||||||
UINT8 patch(QString path, QString fileGuid, QString findPattern, QString replacePattern);
|
UINT8 patch(QString path, QString fileGuid, QString findPattern, QString replacePattern);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
#include "uefipatch.h"
|
#include "uefipatch.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -27,13 +28,17 @@ int main(int argc, char *argv[])
|
||||||
UINT8 result = ERR_SUCCESS;
|
UINT8 result = ERR_SUCCESS;
|
||||||
UINT32 argumentsCount = a.arguments().length();
|
UINT32 argumentsCount = a.arguments().length();
|
||||||
|
|
||||||
if (argumentsCount == 2) {
|
QString patches = "patches.txt";
|
||||||
result = w.patchFromFile(a.arguments().at(1));
|
if (argumentsCount == 3)
|
||||||
|
patches = a.arguments().at(2);
|
||||||
|
|
||||||
|
if (argumentsCount == 2 || argumentsCount == 3) {
|
||||||
|
result = w.patchFromFile(a.arguments().at(1), patches);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cout << "UEFIPatch 0.3.14 - UEFI image file patching utility" << std::endl << std::endl <<
|
std::cout << "UEFIPatch 0.3.14 - UEFI image file patching utility" << std::endl << std::endl <<
|
||||||
"Usage: UEFIPatch image_file" << std::endl << std::endl <<
|
"Usage: UEFIPatch image_file [patches.txt]" << std::endl << std::endl <<
|
||||||
"Patches will be read from patches.txt file\n";
|
"Patches will be read from patches.txt file by default\n";
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +62,7 @@ int main(int argc, char *argv[])
|
||||||
std::cout << "Pattern format mismatch" << std::endl;
|
std::cout << "Pattern format mismatch" << std::endl;
|
||||||
break;
|
break;
|
||||||
case ERR_INVALID_FILE:
|
case ERR_INVALID_FILE:
|
||||||
std::cout << "patches.txt file not found or can't be read" << std::endl;
|
std::cout << patches.toStdString() << " file not found or can't be read" << std::endl;
|
||||||
break;
|
break;
|
||||||
case ERR_FILE_OPEN:
|
case ERR_FILE_OPEN:
|
||||||
std::cout << "Input file not found" << std::endl;
|
std::cout << "Input file not found" << std::endl;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue