~ubuntu-branches/ubuntu/precise/p7zip/precise-updates

« back to all changes in this revision

Viewing changes to CPP/7zip/Archive/7z/7zFolderOutStream.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mohammed Adnène Trojette
  • Date: 2009-02-14 20:12:27 UTC
  • mfrom: (1.1.11 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090214201227-go63qxm9ozfdma60
Tags: 4.65~dfsg.1-1
* New upstream release.
* Remove wx2.8 Build-Depends added by mistakes (7zG is not yet
  intended to be built).
* Use dh_clean without -k.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
    const CArchiveDatabaseEx *archiveDatabase,
18
18
    UInt32 ref2Offset,
19
19
    UInt32 startIndex,
20
 
    const CBoolVector *extractStatuses, 
 
20
    const CBoolVector *extractStatuses,
21
21
    IArchiveExtractCallback *extractCallback,
22
22
    bool testMode,
23
23
    bool checkCrc)
41
41
{
42
42
  Int32 askMode;
43
43
  if((*_extractStatuses)[_currentIndex])
44
 
    askMode = _testMode ? 
 
44
    askMode = _testMode ?
45
45
        NArchive::NExtract::NAskMode::kTest :
46
46
        NArchive::NExtract::NAskMode::kExtract;
47
47
  else
54
54
  _outStreamWithHashSpec->SetStream(realOutStream);
55
55
  _outStreamWithHashSpec->Init(_checkCrc);
56
56
  if (askMode == NArchive::NExtract::NAskMode::kExtract &&
57
 
      (!realOutStream)) 
 
57
      (!realOutStream))
58
58
  {
59
 
    const CFileItem &fileInfo = _archiveDatabase->Files[index];
60
 
    if (!fileInfo.IsAnti && !fileInfo.IsDirectory)
 
59
    const CFileItem &fi = _archiveDatabase->Files[index];
 
60
    if (!_archiveDatabase->IsItemAnti(index) && !fi.IsDir)
61
61
      askMode = NArchive::NExtract::NAskMode::kSkip;
62
62
  }
63
63
  return _extractCallback->PrepareOperation(askMode);
68
68
  for(;_currentIndex < _extractStatuses->Size(); _currentIndex++)
69
69
  {
70
70
    UInt32 index = _startIndex + _currentIndex;
71
 
    const CFileItem &fileInfo = _archiveDatabase->Files[index];
72
 
    if (!fileInfo.IsAnti && !fileInfo.IsDirectory && fileInfo.UnPackSize != 0)
 
71
    const CFileItem &fi = _archiveDatabase->Files[index];
 
72
    if (!_archiveDatabase->IsItemAnti(index) && !fi.IsDir && fi.Size != 0)
73
73
      return S_OK;
74
74
    RINOK(OpenFile());
75
 
    RINOK(_extractCallback->SetOperationResult(
76
 
        NArchive::NExtract::NOperationResult::kOK));
 
75
    RINOK(_extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
77
76
    _outStreamWithHashSpec->ReleaseStream();
78
77
  }
79
78
  return S_OK;
80
79
}
81
80
 
82
 
STDMETHODIMP CFolderOutStream::Write(const void *data, 
 
81
STDMETHODIMP CFolderOutStream::Write(const void *data,
83
82
    UInt32 size, UInt32 *processedSize)
84
83
{
85
84
  UInt32 realProcessedSize = 0;
88
87
    if (_fileIsOpen)
89
88
    {
90
89
      UInt32 index = _startIndex + _currentIndex;
91
 
      const CFileItem &fileInfo = _archiveDatabase->Files[index];
92
 
      UInt64 fileSize = fileInfo.UnPackSize;
 
90
      const CFileItem &fi = _archiveDatabase->Files[index];
 
91
      UInt64 fileSize = fi.Size;
93
92
      
94
 
      UInt32 numBytesToWrite = (UInt32)MyMin(fileSize - _filePos, 
 
93
      UInt32 numBytesToWrite = (UInt32)MyMin(fileSize - _filePos,
95
94
          UInt64(size - realProcessedSize));
96
95
      
97
96
      UInt32 processedSizeLocal;
98
 
      RINOK(_outStreamWithHash->Write((const Byte *)data + realProcessedSize, 
 
97
      RINOK(_outStreamWithHash->Write((const Byte *)data + realProcessedSize,
99
98
            numBytesToWrite, &processedSizeLocal));
100
99
 
101
100
      _filePos += processedSizeLocal;
103
102
      if (_filePos == fileSize)
104
103
      {
105
104
        bool digestsAreEqual;
106
 
        if (fileInfo.IsFileCRCDefined && _checkCrc)
107
 
          digestsAreEqual = fileInfo.FileCRC == _outStreamWithHashSpec->GetCRC();
 
105
        if (fi.CrcDefined && _checkCrc)
 
106
          digestsAreEqual = fi.Crc == _outStreamWithHashSpec->GetCRC();
108
107
        else
109
108
          digestsAreEqual = true;
110
109
 
111
110
        RINOK(_extractCallback->SetOperationResult(
112
 
            digestsAreEqual ? 
 
111
            digestsAreEqual ?
113
112
            NArchive::NExtract::NOperationResult::kOK :
114
113
            NArchive::NExtract::NOperationResult::kCRCError));
115
114
        _outStreamWithHashSpec->ReleaseStream();