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

CZipString CZipArchive::PredictFileNameInZip ( LPCTSTR  lpszFilePath,
bool  bFullPath,
int  iWhat = prAuto,
bool  bExactly = false 
) const

Given the file path in the form it would be passed to AddNewFile as lpszFilePath argument, the function returns the file name as it would be stored in the archive.
The function takes into account the root path set with SetRootPath. You can use this function to eliminate duplicates before adding a list of files.

lpszFilePath the file path as it would be passed to AddNewFile function
bFullPath the same as bFullPath in AddNewFile
iWhat one of Predict values to treat lpszFilePath correctly
bExactly if true, return the filename exactly as it would look inside the archive i.e. convert slash to backslash, and perform ANSI->OEM conversion; otherwise return the filename with the path separators that are used by default in the system
a modified file path

Definition at line 2257 of file ziparchive.cpp.

References CZipPathComponent::AppendSeparator(), ZipCompatibility::FileNameUpdate(), CZipFileHeader::GetFileName(), CZipString::GetLength(), CZipPathComponent::GetNoDrive(), CZipString::IsEmpty(), CZipPathComponent::IsSeparator(), m_bRemoveDriveLetter, m_iArchiveSystCompatib, prDir, prFile, CZipPathComponent::RemoveSeparators(), CZipFileHeader::SetFileName(), CZipFileHeader::SetSystemCompatibility(), and TrimRootPath().

Referenced by WillBeDuplicated().

      CZipString sz = lpszFilePath;
      if (sz.IsEmpty())
            return _T("");
      bool bAppend;
      switch (iWhat)
      case prFile:
            bAppend = false;
      case prDir:
            bAppend = true;
            bAppend = CZipPathComponent::IsSeparator(sz[sz.GetLength() - 1]);

      // remove for CZipPathComponent treating last name as a file even if dir
      CZipPathComponent zpc(sz);

      if (bFullPath)
            if (m_bRemoveDriveLetter)
                  sz = zpc.GetNoDrive();
            sz = TrimRootPath(zpc);

      if (bAppend && !sz.IsEmpty())
      CZipFileHeader fh; // create a temporary object to convert
      if (bExactly)
            ZipCompatibility::FileNameUpdate(fh, false);
            fh.SetSystemCompatibility(-1); // non existing system to prevent ansi oem conversion
            ZipCompatibility::FileNameUpdate(fh, true);// update only path separators

      return fh.GetFileName();

Generated by  Doxygen 1.6.0   Back to index