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