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 =
const int num_args = sizeof( names ) / sizeof( names );
NCOM::CPropVariant values[num_args] =
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 :)
Use "0" instead of "m0".
Excellent .. works now :) Are the strings to set the different methods defined as constants anywhere?
How do I set the compression method for different items in the archive?
1) create archive with lzma.
2) then update it with ppmd to new archive.
Sorry, Could you explain that a little more with code examples.
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.
So if I had a mix of methods, for example:
File1 - LZMA
File2 - PPMD
File3 - LZMA
I'd have to repeat the cycle you have outlined above?
Compess first group with LZMA at first step.
Then update archive with all other files with PPMD
Won't that change the order of the files in the archive?…..
7-Zip can change the order of files in other cases too.
Why the order is important for you?
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,
Release archive objects and stream objects when they are not required anymore.
Should I be using the same update callback or should it be recreated for the second IOutArchive?
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.
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,
STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 index,
Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive)
if (index < number_Of_old_Items)
*newData = 0;
*newProperties = 0
*indexInArchive = index
*newData = 1;
*newProperties = 1
*indexInArchive = -1;
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?
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?
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.
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.
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.
Try to write SFX data stream to outStream before UpdateItems.
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:
m_archive->GetProperty(i, kpidEncrypted, &prop );
if ( prop.boolVal == VARIANT_TRUE )
1) create a2.7z with your code.
2) create simple arvchive with p7zip:
7z a a2.7z 1.txt
7z l a1.7z -slt
7z l a2.7z -slt
and look method field.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.