I am writing a program that downloads tar.xz files from a server and extracts them in a certain place. I am struggling to find a away of extracting the tar.xz file in the certain place. I am using Qt so a more Qt-way of doing it would be useful, but I don't really mind.
Asked
Active
Viewed 4,002 times
1 Answers
2
There is no support for archives in Qt. You can either have a look at the KDE library which offers support for virtual file systems or you can use QProcess
to call tar
directly. Use -C <dir>
(uppercase C) to specify the directory to extract to.
[EDIT] There also is libtar (BSD license).

Aaron Digulla
- 321,842
- 108
- 597
- 820
-
I would prefere not to use QProcess because I would like my application to run on windows as well and using QProcess would mean I would have to ship with tar for windows. Maybe someone could give me a tutorial on liblzma. – Tom Leese Jul 27 '10 at 13:03
-
That lib won't allow you to read the tar archive. If ".xz" is not a typo, then liblzma will only allow you to decompress the archive. But usually tar archives are compressed with bzip2 (.bz2) or gzip (.gz). For these, you probably need other libraries. – Aaron Digulla Jul 27 '10 at 13:06
-
-
Yes but you have *two* containers inside of each other. You have the GZip container and inside of that a Tar container. Unzipping the file just gives you an uncompressed tar archive. How do you plan to read the files from that? – Aaron Digulla Jul 27 '10 at 13:19
-
-
Then you must turn the source for tar into a library and link your code against it :-) Note that GNU tar is GPL so if you use that, your product will also be GPL'd. – Aaron Digulla Jul 27 '10 at 13:25
-
1