How to use xzminidec

  • trfd

    trfd - 2014-11-13

    Hi, I am new to C programing so I can't figure out how to actually use xzminidec. I compiled it and when I run ./xzminidec test.tar.xz or ./xzminidec test.tar.xz test nothing happens as the program "thinks for ever". How is it intended to be used? I build test.tar.xz with tar cf test.tar test ; xz --check=crc32 test.tar.

  • Lasse Collin

    Lasse Collin - 2014-11-17

    xzminidec reads from stdin and writes to stdout so you should do something like this: ./xzminidec < test.tar.xz | tar xf -

    xzminidec understands --help argument but ignores everything else. Ignoring the arguments can help if you are replacing xz with xzminidec when using scripts that run xz -dc, but otherwise it's probably a bit confusing behavior.

    xzminidec is primarily a demo program meant to be useful for programmers who plan to use XZ Embedded. Especially the lack of support for concatenated .xz streams can be a problem that isn't immediately obvious but can bite with some real-world files (xzminidec silently ignores the streams after the first stream). Using xzdec from XZ Utils tends to be a safer choice when you don't control the creation of the input files.

    If you end up using xzminidec you might want to check the compile-time defines which affect the features and size of the resulting xzminidec. They are in Makefile in BCJ_CPPFLAGS and CPPFLAGS variables. They are documented in README and xz.h.

  • trfd

    trfd - 2014-11-19

    Thanks for the explanation! This will do the job on Linux and Mac - I have full control over the creation of the input files. Is there any example of how one can use XZ Embedded to decompress files on Windows?

    Last edit: trfd 2014-11-19
  • Lasse Collin

    Lasse Collin - 2014-11-20

    Maybe one needs to set stdin and stdout to binary mode in xzminidec to make it work on Windows. I don't know what else it could need.

    /* Near the top of the file */
    #include <fcntl.h>
    #include <io.h>
    /* Before xz_crc32_init() in main() */
    setmode(fileno(stdin), O_BINARY);
    setmode(fileno(stdout), O_BINARY);

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks