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

int CZipArchive::CloseFile ( LPCTSTR  lpszFilePath = NULL,
bool  bAfterException = false 
)

Close the file opened for extraction in the archive and copy its date and attributes to the file pointed by lpszFilePath

Parameters:
lpszFilePath Points to the path of the file to have the date and attributes information updated.
bAfterException Set to true to close the file inside archive after an exception has been thrown, to allow futher operations on the archive.
Warning:
Close the file pointed by lpszFilePath before using this method, because the system may not be able to retrieve information from it.
Returns:

  • "1" = ok
  • "-1" = some bytes left to uncompress - probably due to a bad password or corrupted archive
  • "-2" = setting extracted file date and attributes was not successful
Note:
Throws exceptions.

Definition at line 476 of file ziparchive.cpp.

References CZipException::badCrc, CZipCentralDir::CloseFile(), CurrentFile(), EmptyPtrList(), extract, m_bIgnoreCRC, m_centralDir, m_iFileOpened, m_info, CZipArchive::CZipInternalInfo::m_stream, CZipArchive::CZipInternalInfo::m_uCrc32, CZipArchive::CZipInternalInfo::m_uUncomprLeft, nothing, CZipArchive::CZipInternalInfo::ReleaseBuf(), ZipPlatform::SetFileModTime(), and ThrowError().

{
      if (m_iFileOpened != extract)
      {
            TRACE(_T("%s(%i) : No opened file.\n"),__FILE__,__LINE__);
            return false;
      }

      int iRet = 1;
      if (!bAfterException)
      {
            if (m_info.m_uUncomprLeft == 0)
            {
                  if (!m_bIgnoreCRC && m_info.m_uCrc32 != CurrentFile()->m_uCrc32)
                        ThrowError(CZipException::badCrc);
            }
            else
                  iRet = -1;


            if (CurrentFile()->m_uMethod == Z_DEFLATED)
                  inflateEnd(&m_info.m_stream);


            if (lpszFilePath)
            {

                  if (!ZipPlatform::SetFileModTime(lpszFilePath, CurrentFile()->GetTime())
                        ||!ZipPlatform::SetFileAttr(lpszFilePath, CurrentFile()->GetSystemAttr()))
                              iRet = -2;
            }

      }

      m_centralDir.CloseFile(bAfterException);

      m_iFileOpened = nothing;
      m_info.ReleaseBuf();
      EmptyPtrList();
      return iRet;
}


Generated by  Doxygen 1.6.0   Back to index