Search code examples
cxz

Unpack .xz file within C code


My question is quite simple. Is there any possible way to unpack packed .xz file in from C code? I would probably call some default linux-integrated program to unpack it for me, but how exactly does it work? I call the external function and than somehow I get directly back to the program content of the extracted file? Let's say that inside the .xz file is text file and I want to read it afterwards.


Solution

  • I would use system("xz -dl file.xz"), but there is good info here and links to source code to implementations: http://tukaani.org/xz/format.html