IOutArchive->UpdateItems

Anonymous
2012-05-10
2012-12-07
1 2 3 > >> (Page 1 of 3)
  • Anonymous - 2012-05-10

    Hi,

    How do I set the compression method if I'm using the IOutArchive->UpdateItems call?  I'm trying to use the "SetProperties" interface but keep getting E_INVALIDARG.

                const wchar_t *names[] =
                {
                    L"s",
                    L"m0"
                };
                const int num_args = sizeof( names ) / sizeof( names[0] );
                NCOM::CPropVariant values[num_args] =
                {
                    //L"BZip2",
                    //L"LBZip2"
                   false,
                    L"PPMd"
                };
                HRESULT result = set_props->SetProperties(names, values, num_args);
    

    I know it's calling the interface correctly as the "s" (solid) set works.

    Any help please :)

    Mark

     
  • Igor Pavlov

    Igor Pavlov - 2012-05-11

    Use "0" instead of "m0".

     
  • Anonymous - 2012-05-11

    Excellent .. works now :)  Are the strings to set the different methods defined as constants anywhere?

     
  • Anonymous - 2012-05-11

    How do I set the compression method for different items in the archive?

     
  • Igor Pavlov

    Igor Pavlov - 2012-05-11

    1) create archive with lzma.
    2) then update it with ppmd to new archive.

     
  • Anonymous - 2012-05-11

    Sorry, Could you explain that a little more with code examples.

    Thanks,

    Mark

     
  • Igor Pavlov

    Igor Pavlov - 2012-05-11

    1) create archive1.7z with lzma.
    2) Сlose it.
    3) Open archive1.7z with IInArchive.
    4) Request IOutArchive from open archive.
    5) Set ppmd method
    6) call UpdateItems to archive2.7z.

     
  • Anonymous - 2012-05-11

    Hi,

    So if I had a mix of methods, for example:

    File1 - LZMA
    File2 - PPMD
    File3 - LZMA
    File4  PPMD

    I'd have to repeat the cycle you have outlined above?

     
  • Igor Pavlov

    Igor Pavlov - 2012-05-11

    Compess first group with LZMA at first step.
    Then update archive with all other files with PPMD

     
  • Anonymous - 2012-05-11

    Won't that change the order of the files in the archive?…..

     
  • Igor Pavlov

    Igor Pavlov - 2012-05-12

    7-Zip can change the order of files in other cases too.
    Why the order is important for you?

     
  • Anonymous - 2012-05-13

    I'd like to be able to take an archive apart, and then recreate it as the original.  I've tried your steps above… I create the archive, then close it.  Open it again and get the IOutArchive interface and then add the items … this seems to work.  However, if I try and open the archive again I get an exception thrown from IInArchive->Open … are there any special calls I need to make on either the IInArchive or IOutArchive to ensure that they are closed at the end of each cycle.

    Thanks for your help,

    Mark

     
  • Igor Pavlov

    Igor Pavlov - 2012-05-13

    Release archive objects and stream objects when they are not required anymore.

     
  • Anonymous - 2012-05-13

    Should I be using the same update callback or should it be recreated for the second IOutArchive?

     
  • Igor Pavlov

    Igor Pavlov - 2012-05-14

    Maybe it's possible to use same callback.
    But it's simpler to use new instance.
    Note that in second callback you must provide the list of items (just indices of items) that will be copied to new archive from old archive.

     
  • Anonymous - 2012-05-14

    Hi,

    Thanks for getting back to me… not sure I understand what you mean by "provide the list of items (just indices of items) that will be copied to new archive from old archive…" Could you explain with a quick example and what method calls I need to make?

    Thanks in advance,

    Mark

     
  • Igor Pavlov

    Igor Pavlov - 2012-05-14

    STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 index,
          Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive)
    if (index < number_Of_old_Items)
    {
    *newData = 0;
    *newProperties = 0
    *indexInArchive = index
    }
    else
    {
    *newData = 1;
    *newProperties = 1
    *indexInArchive = -1;
    }

     
  • Anonymous - 2012-05-14

    Hi,

    When calling UpdateItems is the numItems argument the number of files being ADDED or the total number of files in the archive, including the ones already in there from the previous updateItems?

     
  • Anonymous - 2012-05-14

    Hi,

    If I add a single LZMA file.  Close the archive .  Re-Open and add a PPMD file.  On the second UpdateItems call, if I set numItems to 1 I get a single file in the output archive.  If I set it to 2 then I have a problem with GetProperty as I am initialising the UpdateCallback with a Vector of 1 item and hence index 1 is not in the vector.  Should GetProperty and GetStream have to take into account the number of existing items as GetUpdateItemInfo does?

    Thanks,

    Mark

     
  • Igor Pavlov

    Igor Pavlov - 2012-05-14

    1) numItems - the number of items in new (second) archive.
    2) look my code above for GetUpdateItemInfo. number_Of_old_Items = 1 in your example.

     
  • Anonymous - 2012-05-14

    Hi,

    Thanks, that makes sense :)  Seems to work successfully now.  I updated GetProperty and GetStream to take off the number of existing items before accessing my new_children vector.

    Thanks for all your help.

    Mark

     
  • Anonymous - 2012-05-14

    Sorry, another question.  Can i create a SFX using the IOutArchive automatically?  Or do I have to take the SFX from the front of the xisting archive and put it onto the output file.

    Thanks,

    Mark

     
  • Igor Pavlov

    Igor Pavlov - 2012-05-14

    Try to write SFX data stream to outStream before UpdateItems.

     
  • Anonymous - 2012-05-14

    Excellent .. that works :)

    Have another "issue" …. I'm using p7zip on Linux .. and the archives I rebuild using UpdateItems seem to have the kpidEncrypted flag set to TRUE by default?  The data being extracted is correct but the flag isn't.  Any ideas?  I'm using:

                               

    NCOM::CPropVariant prop;
                                m_archive->GetProperty(i, kpidEncrypted, &prop );
                                if ( prop.boolVal == VARIANT_TRUE )
                                {
                                }
    
     
  • Igor Pavlov

    Igor Pavlov - 2012-05-15

    1) create a2.7z with your code.
    2) create simple arvchive with p7zip:
    7z a a2.7z 1.txt
    then call
    7z l a1.7z -slt
    7z l a2.7z -slt
    and look method field.

     
1 2 3 > >> (Page 1 of 3)

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks