misc/libphysfs/lzma/CPP/7zip/UI/Common/UpdateProduce.cpp
changeset 12213 bb5522e88ab2
equal deleted inserted replaced
12212:ea891871f481 12213:bb5522e88ab2
       
     1 // UpdateProduce.cpp
       
     2 
       
     3 #include "StdAfx.h"
       
     4 
       
     5 #include "UpdateProduce.h"
       
     6 
       
     7 using namespace NUpdateArchive;
       
     8 
       
     9 static const char *kUpdateActionSetCollision =
       
    10     "Internal collision in update action set";
       
    11 
       
    12 void UpdateProduce(
       
    13     const CObjectVector<CUpdatePair> &updatePairs,
       
    14     const NUpdateArchive::CActionSet &actionSet,
       
    15     CObjectVector<CUpdatePair2> &operationChain)
       
    16 {
       
    17   for(int i = 0; i < updatePairs.Size(); i++)
       
    18   {
       
    19     // CUpdateArchiveRange aRange;
       
    20     const CUpdatePair &pair = updatePairs[i];
       
    21 
       
    22     CUpdatePair2 pair2;
       
    23     pair2.IsAnti = false;
       
    24     pair2.ArchiveItemIndex = pair.ArchiveItemIndex;
       
    25     pair2.DirItemIndex = pair.DirItemIndex;
       
    26     pair2.ExistInArchive = (pair.State != NPairState::kOnlyOnDisk);
       
    27     pair2.ExistOnDisk = (pair.State != NPairState::kOnlyInArchive && pair.State != NPairState::kNotMasked);
       
    28     switch(actionSet.StateActions[pair.State])
       
    29     {
       
    30       case NPairAction::kIgnore:
       
    31         /*
       
    32         if (pair.State != NPairState::kOnlyOnDisk)
       
    33           IgnoreArchiveItem(m_ArchiveItems[pair.ArchiveItemIndex]);
       
    34         // cout << "deleting";
       
    35         */
       
    36         break;
       
    37       case NPairAction::kCopy:
       
    38         {
       
    39           if (pair.State == NPairState::kOnlyOnDisk)
       
    40             throw kUpdateActionSetCollision;
       
    41           pair2.NewData = pair2.NewProperties = false;
       
    42           operationChain.Add(pair2);
       
    43           break;
       
    44         }
       
    45       case NPairAction::kCompress:
       
    46         {
       
    47           if (pair.State == NPairState::kOnlyInArchive || 
       
    48             pair.State == NPairState::kNotMasked)
       
    49             throw kUpdateActionSetCollision;
       
    50           pair2.NewData = pair2.NewProperties = true;
       
    51           operationChain.Add(pair2);
       
    52           break;
       
    53         }
       
    54       case NPairAction::kCompressAsAnti:
       
    55         {
       
    56           pair2.IsAnti = true;
       
    57           pair2.NewData = pair2.NewProperties = true;
       
    58           operationChain.Add(pair2);
       
    59           break;
       
    60         }
       
    61     }
       
    62   }
       
    63 }