I'm trying to copy a file I have attached to my program like resource in a /usr/share/postgresql/10/extension/
(needs sudo
rights)
If the destination path was in /home
I could do something like that:
QFile file(QStringLiteral(":/resourcefile"));
if(file.open(QIODevice::ReadOnly))
{
file.copy("/home/user/......./resourcefile");
}
But it's not my case. Therefore I must to use QProcess (I think) in this way:
QProcess process1, process2;
process1.setStandardOutputProcess(&process2);
process1.start("echo mypass");
process2.start("sudo -S cp <resourcefile> /usr/share/postgresql/10/extension/file.sql");
process2.setProcessChannelMode(QProcess::ForwardedChannels);
bool retval = false;
QByteArray buffer;
while ((retval = process2.waitForFinished()));
buffer.append(process2.readAll());
.....
And the question is....how could I pass the <resourcefile>
to process2?