コード例 #1
0
 private void MapBlock(IZipIOBlock block)
 {
     for (int i = this._blockList.Count - 1; i >= 0; i--)
     {
         ZipIORawDataFileBlock block2 = this._blockList[i] as ZipIORawDataFileBlock;
         if ((block2 != null) && block2.DiskImageContains(block))
         {
             ZipIORawDataFileBlock block3;
             ZipIORawDataFileBlock block4;
             block2.SplitIntoPrefixSuffix(block, out block4, out block3);
             this._blockList.RemoveAt(i);
             if (block3 != null)
             {
                 this._blockList.Insert(i, block3);
             }
             this._blockList.Insert(i, block);
             if (block4 != null)
             {
                 this._blockList.Insert(i, block4);
             }
             return;
         }
     }
     throw new FileFormatException(SR.Get("CorruptedData"));
 }
コード例 #2
0
 public void UpdateReferences(bool closingFlag)
 {
     foreach (IZipIOBlock block3 in (IEnumerable)this._blockManager)
     {
         ZipIOLocalFileBlock   fileBlock = block3 as ZipIOLocalFileBlock;
         ZipIORawDataFileBlock block     = block3 as ZipIORawDataFileBlock;
         if (fileBlock != null)
         {
             ZipIOCentralDirectoryFileHeader header2 = (ZipIOCentralDirectoryFileHeader)this.CentralDirectoryDictionary[fileBlock.FileName];
             if (header2.UpdateIfNeeded(fileBlock))
             {
                 this._dirtyFlag = true;
             }
         }
         else if (block != null)
         {
             long diskImageShift = block.DiskImageShift;
             if (diskImageShift != 0L)
             {
                 foreach (ZipIOCentralDirectoryFileHeader header in this.CentralDirectoryDictionary.Values)
                 {
                     if (block.DiskImageContains(header.OffsetOfLocalHeader))
                     {
                         header.MoveReference(diskImageShift);
                         this._dirtyFlag = true;
                     }
                 }
                 continue;
             }
         }
     }
 }
コード例 #3
0
 // Methods
 internal ZipIOBlockManager(Stream archiveStream, bool streaming, bool ownStream)
 {
     this._archiveStream = archiveStream;
     this._openStreaming = streaming;
     this._ownStream     = ownStream;
     if (streaming)
     {
         this._archiveStream = new WriteTimeStream(this._archiveStream);
     }
     else if (archiveStream.Length > 0L)
     {
         ZipIORawDataFileBlock block = ZipIORawDataFileBlock.Assign(this, 0L, archiveStream.Length);
         this._blockList.Add(block);
     }
 }
コード例 #4
0
        internal static ZipIORawDataFileBlock Assign(ZipIOBlockManager blockManager, long offset, long size)
        {
            if (size <= 0L)
            {
                throw new ArgumentOutOfRangeException("size");
            }
            if (offset < 0L)
            {
                throw new ArgumentOutOfRangeException("offset");
            }
            ZipIORawDataFileBlock block = new ZipIORawDataFileBlock(blockManager);

            block._persistedOffset = offset;
            block._offset          = offset;
            block._size            = size;
            return(block);
        }
コード例 #5
0
 internal void SplitIntoPrefixSuffix(IZipIOBlock block, out ZipIORawDataFileBlock prefixBlock, out ZipIORawDataFileBlock suffixBlock)
 {
     prefixBlock = null;
     suffixBlock = null;
     if (block.Offset > this._persistedOffset)
     {
         long offset = this._persistedOffset;
         long size   = block.Offset - this._persistedOffset;
         prefixBlock = Assign(this._blockManager, offset, size);
     }
     if ((block.Offset + block.Size) < (this._persistedOffset + this._size))
     {
         long num  = block.Offset + block.Size;
         long num2 = (this._persistedOffset + this._size) - num;
         suffixBlock = Assign(this._blockManager, num, num2);
     }
 }