1 // UpdateProduce.cpp 2 3 #include "StdAfx.h" 4 5 #include "UpdateProduce.h" 6 7 using namespace NUpdateArchive; 8 9 static const char *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 (int i = 0; i < updatePairs.Size(); i++) 18 { 19 const CUpdatePair &pair = updatePairs[i]; 20 21 CUpdatePair2 up2; 22 up2.IsAnti = false; 23 up2.DirIndex = pair.DirIndex; 24 up2.ArcIndex = pair.ArcIndex; 25 up2.NewData = up2.NewProps = true; 26 27 switch(actionSet.StateActions[pair.State]) 28 { 29 case NPairAction::kIgnore: 30 /* 31 if (pair.State != NPairState::kOnlyOnDisk) 32 IgnoreArchiveItem(m_ArchiveItems[pair.ArcIndex]); 33 // cout << "deleting"; 34 */ 35 if (callback) 36 callback->ShowDeleteFile(pair.ArcIndex); 37 continue; 38 39 case NPairAction::kCopy: 40 if (pair.State == NPairState::kOnlyOnDisk) 41 throw kUpdateActionSetCollision; 42 up2.NewData = up2.NewProps = false; 43 break; 44 45 case NPairAction::kCompress: 46 if (pair.State == NPairState::kOnlyInArchive || 47 pair.State == NPairState::kNotMasked) 48 throw kUpdateActionSetCollision; 49 break; 50 51 case NPairAction::kCompressAsAnti: 52 up2.IsAnti = true; 53 break; 54 } 55 operationChain.Add(up2); 56 } 57 operationChain.ReserveDown(); 58 } 59