I want to write a c-program which reads a textfile from a tar.gz archive.
How can I do it?
Use GNU tar and extract the file to stdout
tar -zxvOf filename.tar.gz somepath/yourfile.txt
The '-O' option tells tar to extract it to stdout.
If your using KDE there's one built-in, its called Archiver.
That's not what I wanted to now. My question was, if there is a function in c which allows to read a textfile from a tar.gz archive and put it in a variable.
yes, there are a number of functions to use to call an outside program. you can use exec() to call GNU tar. i think i understand what you want to do, youd like to actually write the code to uncompress the archive your self, while yes you can do that, it is (arguably) a large amount of work that you dont have to do, you already have tar. if you really want to write your own archiver/decompressor you could always look at the source of gnu tar to start you off.
let me add though, that if you just want to let a user pick an archive and read the text file inside of it from within your program then all you need to do is call tar from exec().
Hi,
i have tried to do it.....but....the system tell me that -x is invalidate option.....i wish to uncompress a file.....Do you have any suggestion or idea please?....
Thanks in advance,
Mary
Tried to do what? Run the line of code listed above, in the second post? Which system / shell are you running on?
Download zlib.
There is a directory "untgz" containing a C file for reading/extracting gzipped tarballs which uses zlib.
I don't know whether it works or not, however.
Hi!!!...
I already know why i couldnt....
This is because my kind the unix that i am using doesnt' have it kind of library (gzip).....
I already could uncompress it file.tar.gz in other machine....thanks any way.....
gzip -d file
tar -xvf file
Best regars,
Mary
Does anyone know of a java library for manipulating modern tar file formats (e.g., Posix.1 1988/2001, Gnu tar, etc.)? I tried using Apache's tar classes from the Ant project, but they don't support large (>8Gb) tar entries). Project time constraints are pushing me to look for an out-of-the-box solution. Thanks!