How to programatically add 2 files, one with 'Copy' one with 'LZMA'

  • skybow


    in our project, we want to integrate 7zip (statically linked for this is company policy) to do the following: We have a SQL-DB backup procedure consisting of several files. For makeing support life easier, our application needs to put all files into one archive.

    The main file can get very large (the largest sample being almost 7GB right now with the size tending to grow, and which is the reason to use 7zip, since it can handle large files). This file is already in some compressed form (the DB file gets so big since we store a lot of JPG data) so I don't want to compress this file again (no need to make the user wait for another hour...).

    I started off from the Client7z.cpp sample code replacing the DLL dependencies (since I don't need them). But I face the following problems:

    (1.) In one pass, I cannot add files with different compression methods (one with 'Copy' the others with 'default'). Is there a way to switch the compression method while processing files in NArchive::N7z::CHandler::UpdateItems?

    (2.) If I try to perform the steps to add files as in Client7z.cpp first for the 'Copy' file and then for the 'default' files, the second step kicks out all files written in the first step.
    From guessing what the codes does, I figured, that 7z does some sort of TEMP file switching stuff, when adding more files to an existing archive. Is there a way to directly append more files to an existing archive or do I have to manage this via some temp files?


  • Igor Pavlov
    Igor Pavlov

    1) no way.
    You can create two archives.

    2) 7-Zip uses temp file for safety. So you will have some working archive even after failure.
    Don't update archive. Just create new archive that contains only new or changed files.