Logo Search packages:      
Sourcecode: harbour version File versions  Download package

bool CZipArchive::ExtractFile ( WORD  uIndex,
CZipMemFile mf,
DWORD  nBufSize = 65536 

The same as ExtractFile(WORD , LPCTSTR , bool , LPCTSTR , DWORD ) but instead to a physical file, this function decompress the data into CZipMemFile object

  • if you pass CZipMemFile object already with data, its contents are NOT overwirtten, but the decompressed data is appended at the end
  • if you try to extract a directory, the function will return false

Definition at line 760 of file ziparchive.cpp.

References CZipException::abortedAction, CZipException::abortedSafely, CZipActionCallback::CallbackEnd(), cbExtract, CloseFile(), GetCallback(), GetFileInfo(), CZipFileHeader::GetFileName(), CZipAutoBuffer::GetSize(), CZipActionCallback::Init(), CZipFileHeader::IsDirectory(), CZipFileHeader::m_uUncomprSize, OpenFile(), ReadFile(), CZipActionCallback::SetTotal(), CZipException::Throw(), and CZipMemFile::Write().

      if (!nBufSize)
            return false;

      CZipFileHeader header;
      GetFileInfo(header, uIndex); // to ensure that slash and oem conversions take place
      CZipActionCallback* pCallback = GetCallback(cbExtract);
      if (pCallback)

      if (header.IsDirectory() || !OpenFile(uIndex))
            return false;

      CZipAutoBuffer buf(nBufSize);
      DWORD iRead;
      int iAborted = 0;
            iRead = ReadFile(buf, buf.GetSize());
            if (iRead)
                  mf.Write(buf, iRead);
                  if (pCallback)
                        if (!(*pCallback)(iRead))
                              if (iRead == buf.GetSize() && ReadFile(buf, 1) != 0) // test one byte if there is something left
                                    iAborted = CZipException::abortedAction;
                                    iAborted = CZipException::abortedSafely; // we did it!
      while (iRead == buf.GetSize());
      bool bRet = CloseFile() == 1;
      if (!bRet && iAborted == CZipException::abortedSafely)
            iAborted = CZipException::abortedAction; // sorry, finished, but not successfull

      if (pCallback)

      if (iAborted)
            CZipException::Throw(iAborted); // throw to distuingiush from other return codes
      return bRet;

Generated by  Doxygen 1.6.0   Back to index