Pregunta

I'm trying to untar a file with QProcess that's in a directory returned by QDir::tempPath(), as follows:

extract.start("tar", QStringList() << "-xvzf" + QDir::tempPath() + "/thefile.tar.gz");

I get the correct output for an extraction by looking at the standardOuput for the QProcess but there's no file extracted at the end. Manually running tar from a shell works fine on the file so I know it's not corrupt, I'd have assumed a permissions issue but I'm actually downloading the file with the application to the temporary directory so the application should have write access.

Edit: I've also now tried it with the file in the home directory, it's definitely there but I get the same results as it being in the temp directory, verbose output indicating success but no resulting file.

¿Fue útil?

Solución

You need to set the working directory, which by default, is likely to be the folder of the executable's binary.

You can set the working directory with QProcess::setWorkingDirectory

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top