문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top