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

void CZipArchive::Close ( int  iAfterException = afNoException,
bool  bUpdateTimeStamp = false 
)

Close the archive.

Parameters:
iAfterException one of CloseAfterException enum values
bUpdateTimeStamp if true, set the modification date of the zip file to the date of the newest file in the archive; in disk-spanning mode only the last archive file will have the time stamp updated; you can use this option even without performing any additional processing on the archive, just open and close it
Note:
Throws exceptions if iAfterException is different from afAfterException

Definition at line 401 of file ziparchive.cpp.

References afAfterException, afNoException, CZipCentralDir::Clear(), CZipStorage::Close(), CloseFile(), CloseNewFile(), compress, extract, IsClosed(), CZipString::IsEmpty(), m_centralDir, CZipCentralDir::m_headers, m_iFileOpened, m_storage, ZipPlatform::SetFileModTime(), and WriteCentralDirectory().

Referenced by AddNewFile().

{
      // if after an exception - the archive may be closed, but the file may be opened
      if (IsClosed() && (!iAfterException || IsClosed(false)))
      {
            TRACE(_T("%s(%i) : ZipArchive is already closed.\n"),__FILE__,__LINE__);
            return;
      }

      if (m_iFileOpened == extract)
            CloseFile(NULL, iAfterException != afNoException);

      if (m_iFileOpened == compress)
            CloseNewFile(iAfterException != afNoException);

      if (iAfterException != afAfterException && !IsClosed(false)) // in disk spanning when user aborts
            WriteCentralDirectory(false);  // we will flush in CZipStorage::Close

      time_t tNewestTime = 0;

      if (bUpdateTimeStamp)
      {
            int iSize = m_centralDir.m_headers.GetSize();
            for (int i = 0; i< iSize; i++)
            {
                  time_t tFileInZipTime = m_centralDir[i]->GetTime();
                  if (tFileInZipTime > tNewestTime)
                        tNewestTime = tFileInZipTime;
            }
      }
      m_centralDir.Clear();
      CZipString szFileName = m_storage.Close(iAfterException == afAfterException);
      if (bUpdateTimeStamp && !szFileName.IsEmpty())
            ZipPlatform::SetFileModTime(szFileName, tNewestTime);
}


Generated by  Doxygen 1.6.0   Back to index