fix problem with copying of new adblock js
This commit is contained in:
parent
0a42d50e54
commit
b743c72a04
2 changed files with 19 additions and 3 deletions
|
@ -93,13 +93,18 @@ bool IOFactory::startProcessDetached(const QString& program, const QStringList&
|
|||
return process.startDetached(nullptr);
|
||||
}
|
||||
|
||||
QString IOFactory::startProcessGetOutput(const QString& executable, const QStringList& arguments) {
|
||||
QString IOFactory::startProcessGetOutput(const QString& executable,
|
||||
const QStringList& arguments,
|
||||
const QProcessEnvironment& pe) {
|
||||
QProcess proc;
|
||||
|
||||
proc.setProgram(executable);
|
||||
proc.setArguments(arguments);
|
||||
proc.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
|
||||
|
||||
QProcessEnvironment system_pe = QProcessEnvironment::systemEnvironment();
|
||||
|
||||
system_pe.insert(pe);
|
||||
proc.setProcessEnvironment(system_pe);
|
||||
proc.start();
|
||||
|
||||
if (proc.waitForFinished() &&
|
||||
|
@ -142,6 +147,14 @@ void IOFactory::writeFile(const QString& file_path, const QByteArray& data) {
|
|||
|
||||
bool IOFactory::copyFile(const QString& source, const QString& destination) {
|
||||
if (QFile::exists(destination)) {
|
||||
QFile file(destination);
|
||||
|
||||
file.setPermissions(file.permissions() |
|
||||
QFileDevice::WriteOwner |
|
||||
QFileDevice::WriteUser |
|
||||
QFileDevice::WriteGroup |
|
||||
QFileDevice::WriteOther);
|
||||
|
||||
if (!QFile::remove(destination)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "definitions/definitions.h"
|
||||
|
||||
#include <QProcessEnvironment>
|
||||
#include <QStandardPaths>
|
||||
|
||||
class IOFactory {
|
||||
|
@ -31,7 +32,9 @@ class IOFactory {
|
|||
const QStringList& arguments,
|
||||
const QString& native_arguments = {},
|
||||
const QString& working_directory = {});
|
||||
static QString startProcessGetOutput(const QString& executable, const QStringList& arguments = {});
|
||||
static QString startProcessGetOutput(const QString& executable,
|
||||
const QStringList& arguments = {},
|
||||
const QProcessEnvironment& pe = {});
|
||||
|
||||
// Returns contents of a file.
|
||||
// Throws exception when no such file exists.
|
||||
|
|
Loading…
Add table
Reference in a new issue