Example #1
0
static HRESULT UpdateItemOldData(
    COutArchive &archive,
    CInArchive *inArchive,
    const CItemEx &itemEx,
    const CUpdateItem &ui,
    CItemOut &item,
    /* bool izZip64, */
    ICompressProgressInfo *progress,
    UInt64 &complexity)
{
  if (ui.NewProps)
  {
    if (item.HasDescriptor())
      return E_NOTIMPL;
    
    // use old name size.
    // CUpdateRange range(item.GetLocalExtraPosition(), item.LocalExtraSize + item.PackSize);
    CUpdateRange range(inArchive->GetOffsetInStream(itemEx.GetDataPosition()), itemEx.PackSize);
    
    // we keep ExternalAttrib and some another properties from old archive
    // item.ExternalAttrib = ui.Attrib;

    item.Name = ui.Name;
    item.SetUtf8(ui.IsUtf8);
    item.Time = ui.Time;
    item.Ntfs_MTime = ui.Ntfs_MTime;
    item.Ntfs_ATime = ui.Ntfs_ATime;
    item.Ntfs_CTime = ui.Ntfs_CTime;
    item.NtfsTimeIsDefined = ui.NtfsTimeIsDefined;

    item.CentralExtra.RemoveUnknownSubBlocks();
    item.LocalExtra.RemoveUnknownSubBlocks();
    item.LocalHeaderPos = archive.GetCurPos();

    archive.PrepareWriteCompressedData2(item.Name.Len(), item.Size, item.PackSize, item.LocalExtra.HasWzAes());
    archive.WriteLocalHeader(item);
    RINOK(WriteRange(inArchive->Stream, archive, range, progress));
    complexity += range.Size;
  }
  else
  {
    CUpdateRange range(inArchive->GetOffsetInStream(itemEx.LocalHeaderPos), itemEx.GetLocalFullSize());
    
    // set new header position
    item.LocalHeaderPos = archive.GetCurPos();
    
    RINOK(WriteRange(inArchive->Stream, archive, range, progress));
    complexity += range.Size;
    archive.MoveCurPos(range.Size);
  }
  return S_OK;
}
Example #2
0
static HRESULT UpdateItemOldData(
    COutArchive &archive,
    CInArchive *inArchive,
    const CItemEx &itemEx,
    const CUpdateItem &ui,
    CItemOut &item,
    /* bool izZip64, */
    ICompressProgressInfo *progress,
    IArchiveUpdateCallbackFile *opCallback,
    UInt64 &complexity)
{
  if (opCallback)
  {
    RINOK(opCallback->ReportOperation(
        NEventIndexType::kInArcIndex, (UInt32)ui.IndexInArc,
        NUpdateNotifyOp::kReplicate))
  }

  if (ui.NewProps)
  {
    if (item.HasDescriptor())
      return E_NOTIMPL;
    
    // use old name size.
    
    CMyComPtr<ISequentialInStream> packStream;
    RINOK(inArchive->GetItemStream(itemEx, true, packStream));
    if (!packStream)
      return E_NOTIMPL;

    // we keep ExternalAttrib and some another properties from old archive
    // item.ExternalAttrib = ui.Attrib;

    item.Name = ui.Name;
    item.SetUtf8(ui.IsUtf8);
    item.Time = ui.Time;
    item.Ntfs_MTime = ui.Ntfs_MTime;
    item.Ntfs_ATime = ui.Ntfs_ATime;
    item.Ntfs_CTime = ui.Ntfs_CTime;
    item.NtfsTimeIsDefined = ui.NtfsTimeIsDefined;

    item.CentralExtra.RemoveUnknownSubBlocks();
    item.LocalExtra.RemoveUnknownSubBlocks();
    item.LocalHeaderPos = archive.GetCurPos();

    archive.PrepareWriteCompressedData2(item.Name.Len(), item.Size, item.PackSize, item.LocalExtra.HasWzAes());
    archive.WriteLocalHeader(item);

    RINOK(CopyBlockToArchive(packStream, itemEx.PackSize, archive, progress));

    complexity += itemEx.PackSize;
  }
  else
  {
    CMyComPtr<ISequentialInStream> packStream;
    RINOK(inArchive->GetItemStream(itemEx, false, packStream));
    if (!packStream)
      return E_NOTIMPL;
    
    // set new header position
    item.LocalHeaderPos = archive.GetCurPos();
    
    const UInt64 rangeSize = itemEx.GetLocalFullSize();
    
    RINOK(CopyBlockToArchive(packStream, rangeSize, archive, progress));

    complexity += rangeSize;
    archive.MoveCurPos(rangeSize);
  }

  return S_OK;
}