PDA

View Full Version : Is there a built-in Qt4 function to unarchive .tar files on Windows?



ronne
4th April 2010, 17:34
I'm using Qt4.6, Qt Creator SDK and MinGW to write a simple program for Windows users to extract tar.gz archived files originally created on Linux.

I have the .gz decompression working with zlib, but I'm wondering if there is an included or built-in function to restore the files and folders contained within the .tar file in a Windows OS.

If not, is libarchive (http://code.google.com/p/libarchive/) a good choice or are there better options to use with Qt4?

Thanks for your advice.

squidge
4th April 2010, 19:58
I believe GZ support is built-in, but not tar, but thats such an easy archive format to support anyway.

A lot of tar.gz files created on Linux will not fully extract on Windows as your moving from a case-sensitive file system to a case insensitive one, and secondly, soft-links are not supported unless you emulate them using NTFS symbolic links and junction points.

If you can live with the above restrictions, then there is gzip, bzip and tar for Windows if you like the command line, and various archivers such as Winrar which support tar.gz files natively.

Is there a reason you want to create your own version of such a tool?

ronne
5th April 2010, 08:05
Thanks for the reply. Personally, I use 7zip and Winrar for such operations.


Is there a reason you want to create your own version of such a tool?
It's not a full featured compression/decompression utility, just an extremely simple program for people running a Windows build of a Linux program which has addons in tar.gz format with a non-standard extension. People seem to have trouble using common utilities like 7zip. My program has the user browse to select the output directory, then drag the file or files to extract them. It's not intended for general decompression, just to ease installing addons for one program.

I'm also using this as an exercise to learn the basics of Qt. The program is already working, except the last step from .tar to extracted archives. Since I'm new to Qt and searches didn't turn up much on the subject, I thought I would ask before going ahead with libarchive.

ronne
6th April 2010, 21:32
In case anyone is searching for this topic, I did have success with libarchive (http://gnuwin32.sourceforge.net/packages/libarchive.htm).

I was able to build a working program based on the included libarchive examples by:

Adding this to my .pro project file:


LIBS += "C:\Program Files\GnuWin32\lib\libarchive.lib"

Putting these files in files in my Qt\2010.02.1\mingw\include folder:


archive.h
archive_entry.h
libarchive-nonposix.h

Then including the .dlls in the folder with my .exe:


libarchive2.dll
bzip2.dll
zlib1.dll