1 // UpdateProduce.cpp 2 3 #include "StdAfx.h" 4 5 #include "UpdateProduce.h" 6 7 using namespace NUpdateArchive; 8 9 static const char * const kUpdateActionSetCollision = "Internal collision in update action set"; 10 UpdateProduce(const CRecordVector<CUpdatePair> & updatePairs,const CActionSet & actionSet,CRecordVector<CUpdatePair2> & operationChain,IUpdateProduceCallback * callback)11void UpdateProduce( 12 const CRecordVector<CUpdatePair> &updatePairs, 13 const CActionSet &actionSet, 14 CRecordVector<CUpdatePair2> &operationChain, 15 IUpdateProduceCallback *callback) 16 { 17 FOR_VECTOR (i, updatePairs) 18 { 19 const CUpdatePair &pair = updatePairs[i]; 20 21 CUpdatePair2 up2; 22 up2.DirIndex = pair.DirIndex; 23 up2.ArcIndex = pair.ArcIndex; 24 up2.NewData = up2.NewProps = true; 25 up2.UseArcProps = false; 26 27 switch (actionSet.StateActions[(unsigned)pair.State]) 28 { 29 case NPairAction::kIgnore: 30 if (pair.ArcIndex >= 0 && callback) 31 callback->ShowDeleteFile(pair.ArcIndex); 32 continue; 33 34 case NPairAction::kCopy: 35 if (pair.State == NPairState::kOnlyOnDisk) 36 throw kUpdateActionSetCollision; 37 if (pair.State == NPairState::kOnlyInArchive) 38 { 39 if (pair.HostIndex >= 0) 40 { 41 /* 42 ignore alt stream if 43 1) no such alt stream in Disk 44 2) there is Host file in disk 45 */ 46 if (updatePairs[pair.HostIndex].DirIndex >= 0) 47 continue; 48 } 49 } 50 up2.NewData = up2.NewProps = false; 51 up2.UseArcProps = true; 52 break; 53 54 case NPairAction::kCompress: 55 if (pair.State == NPairState::kOnlyInArchive || 56 pair.State == NPairState::kNotMasked) 57 throw kUpdateActionSetCollision; 58 break; 59 60 case NPairAction::kCompressAsAnti: 61 up2.IsAnti = true; 62 up2.UseArcProps = (pair.ArcIndex >= 0); 63 break; 64 } 65 66 operationChain.Add(up2); 67 } 68 69 operationChain.ReserveDown(); 70 } 71