📄 ziparchive.h
字号:
*/
CZipString PredictFileNameInZip(LPCTSTR lpszFilePath, bool bFullPath, int iWhat = prAuto, bool bExactly = false)const ;
/**
Check if the filename will be duplicted in the archive, if added to the archive in the given form
\param bFileNameOnly
if \c true, assume that the filename is duplicated if only the filename (no path) is the same (\e bFullPath is ignored), otherwise the whole filename with path is taken into account.
\b Default: \c false
The rest of the parameters have the same meaning as in #PredictFileNameInZip.
\return the zero-based index of the file in the archive that the filename would be duplicated, or -1, if the filename is unique
*/
int WillBeDuplicated(LPCTSTR lpszFilePath, bool bFullPath, bool bFileNameOnly = false, int iWhat = prAuto);
/**
Predict the full filename with path after extraction. The parameters (except for the first) are in the form you'd pass
to the <CODE> #ExtractFile(WORD , LPCTSTR , bool , LPCTSTR , DWORD ) </CODE> function. The function takes into account the root path set with #SetRootPath.
\param lpszFileNameInZip
the filename of the file inside the archive (may be \c NULL if lpszNewName is not \c NULL)
\param lpszPath
\param bFullPath
\param lpszNewName
\return a predicted file path
*/
CZipString PredictExtractedFileName(LPCTSTR lpszFileNameInZip, LPCTSTR lpszPath, bool bFullPath, LPCTSTR lpszNewName = NULL)const ;
/**
Return the current value of #m_szTempPath
\return CZipString
*/
CZipString GetTempPath()const
{
return m_szTempPath;
}
/**
Function used in conjunction with #m_szRootPath to trim paths in #AddNewFile and #ExtractFile
\param zpc
\see SetRootPath
*/
CZipString TrimRootPath(CZipPathComponent& zpc)const ;
/**
Remove \e lpszBeginning from the beginning of the \e szPath. Both argument are
considered to be paths so they matches up to the path separator.
\param lpszBeginning
\param szPath
\param pCompareFunction (see: #m_pZipCompare)
\return \c true if the path beginning was removed
*/
static bool RemovePathBeginning(LPCTSTR lpszBeginning, CZipString& szPath, ZIPSTRINGCOMPARE pCompareFunction);
/**
Set the default archive case-sensitivity. Affects the following functions:
- #FindFile
- #FindMatches
- #EnableFindFast
- #TrimRootPath
- #DeleteFiles
\param bCaseSensitive
the default CZipArchive case-sensitivity depends on the system and is set
as follows:
- on Windows: \c false <BR>
- on Linux: \c true
\note Set it before using one of the functions above or leave it as it is by default;
*/
void SetCaseSensitivity(bool bCaseSensitive)
{
m_bCaseSensitive = bCaseSensitive;
m_pZipCompare = GetCZipStrCompFunc(bCaseSensitive);
}
/**
Return the central directory information.
\see GetCentralDirSize
*/
void GetCentralDirInfo(CZipCentralDir::Info& info)const;
/**
Get the central directory size.
\see CZipCentralDir::GetSize
\see GetCentralDirInfo
*/
DWORD GetCentralDirSize(bool bWhole = true) const
{
return m_centralDir.GetSize(bWhole);
}
/**
return \c true if the archive cannot be modified, because it is an existing disk spanning archive
or it was opened with #zipOpenReadOnly
*/
bool IsReadOnly(){return m_storage.IsReadOnly();}
/**
If you set \e bIgnore to \c true, CRC is not checked for the files being tested or extracted.
This method is useful when working with Java <sup><small>TM</small></sup> Archives (jar).
The CRC is checked by default. You can use this function on an opened or closed archive.
*/
void SetIgnoreCRC(bool bIgnore = true){m_bIgnoreCRC = bIgnore;}
/**
A class used in wildcard pattern matching.
This class is based on code by J. Kercheval, created 01/05/1991
and available as a public domain at http://www.snippets.org.
*/
class ZIP_API CWildcard
{
public:
enum Match
{
matchNone, ///< for internal use
matchValid, ///< valid match
matchEnd, ///< premature end of pattern string
matchAbort, ///< premature end of text string
matchRange, ///< match failure on [..] construct
matchLiteral, ///< match failure on literal match
matchPattern ///< bad pattern
};
enum Pattern
{
patternEmpty = -4, ///< [..] construct is empty
patternClose, ///< no end bracket in [..] construct
patternRange, ///< malformed range in [..] construct
patternEsc, ///< literal escape at end of pattern
patternValid, ///< valid pattern
};
/**
Match the pattern against the string \e lpszText
A match means the entire string \e lpszText is used up in matching.
\param lpszText
the string to match against
\param iRetCode
if not \c NULL, set to one of #Match values indicating the return code
\return \c true if \e lpszText matches the pattern.
\see SetPattern
*/
bool IsMatch(LPCTSTR lpszText, int* iRetCode = NULL);
/**
\param lpszPattern
\return \c true if \e lpszPattern has any special wildcard characters.
*/
static bool IsPattern(LPCTSTR lpszPattern);
/**
Test the pattern for validity.
\param lpszPattern
the pattern to test
\param iErrorType
if not \c NULL, set to one of #Pattern values indicating the return code
\return \c true if \e lpszPattern is a well formed regular expression according
to the CWildcard class syntax (see #SetPattern)
*/
static bool IsPatternValid(LPCTSTR lpszPattern, int* iErrorType = NULL);
/**
Match the pattern \e lpszPattern against the string \e lpszText
A match means the entire string \e lpszText is used up in matching.
\param lpszPattern
see #SetPattern
\param lpszText
the string to match against
\return
one of #Match values
*/
static int Match(LPCTSTR lpszPattern, LPCTSTR lpszText);
CWildcard(){}
/**
Initialize the pattern.
\see SetPattern
*/
CWildcard(LPCTSTR lpszPattern, bool bCaseSensitive)
{
SetPattern(lpszPattern, bCaseSensitive);
}
virtual ~CWildcard(){}
/**
Set the pattern to \e lpszPattern.
\param lpszPattern
In the pattern string:
- * matches any sequence of characters(zero or more)
- ? matches any character
- [SET] matches any character in the specified set,
- [!SET] or[^SET] matches any character not in the specified set.
A set is composed of characters or ranges; a range looks like
character hyphen character(as in 0 - 9 or A - Z).[0 - 9a - zA - Z_] is the
minimal set of characters allowed in the[..] pattern construct.
Other characters are allowed(ie. 8 bit characters) if your system
will support them.
\note To suppress the special syntactic significance of any of []*?!^-\,
and match the character exactly, precede it with a \
*/
void SetPattern(LPCTSTR lpszPattern, bool bCaseSensitive)
{
m_szPattern = lpszPattern;
m_bCaseSensitive=bCaseSensitive;
if (!bCaseSensitive)
m_szPattern.MakeLower();
}
operator LPCTSTR()
{
return (LPCTSTR)m_szPattern;
}
protected:
bool m_bCaseSensitive;
static int MatchAfterStar(LPCTSTR p , LPCTSTR t);
CZipString m_szPattern;
};
/**
This function finds the indexes of the files, which filenames match the specified pattern and stores
these indexes in the array. The indexes can be used then e.g. in deleting (CZipArchive::DeleteFiles) or
extracting files (CZipArchive::ExtractFile).
\param lpszPattern
the pattern to match (see CWildcard::SetPattern on how to build the pattern). The case-sensitivity of the pattern
is set to the global archive case-sensitivity (set with #SetCaseSensitivity)
\param ar
the array which will contain the indexes of the files which filenames match the pattern; the contents of the array are NOT clearead, but the
indexes are appended to it
\param bFullPath <BR>
- if \c true, match the filename with path (if present) of the file (if the file is a directory, end it with the path separator or use a pattern that will recognize it)
- otherwise match only the name of the file (if the file is a directory, do not end it with the path separator)
*/
void FindMatches(LPCTSTR lpszPattern, CZipWordArray& ar, bool bFullPath = true)const;
/**
Change the name of the file with the given index.
\param uIndex
zero-based index of the file
\param lpszNewName
new name for the file
\return
\note Throws exceptions.
\see SetAdvanced
*/
bool RenameFile(WORD uIndex, LPCTSTR lpszNewName);
/**
If \c true, the drive letter is removed from the filename stored inside the archive when adding a new file to the archive. It affects
#AddNewFile, #ExtractFile, #PredictFileNameInZip, #PredictExtractedFileName, #WillBeDuplicated methods.
\b Default: \c true
*/
bool m_bRemoveDriveLetter;
protected:
/**
\param iReplaceIndex index of file to be replaced
\param uTotal the size of the new file to replace existing
\param lpszFileName the filename for callback initialization
*/
void MakeSpaceForReplace(int iReplaceIndex, DWORD uTotal, LPCTSTR lpszFileName);
/**
A structure for the internal use only. Clears the password if necessary and
restores it later (also in case of an exception).
*/
struct ZIP_API CZipSmClrPass
{
void ClearPasswordSmartly(CZipArchive* pZip)
{
m_pZip = pZip;
m_szPass = pZip->GetPassword();
if (!m_szPass.IsEmpty())
pZip->SetPassword();
}
~CZipSmClrPass()
{
if (!m_szPass.IsEmpty())
m_pZip->SetPassword(m_szPass);
}
CZipString m_szPass;
CZipArchive* m_pZip;
};
/**
Holds map of holes and areas to remain when deleting files from the archive.
A structure for the internal use only.
*/
struct ZIP_API CZipDeleteInfo
{
CZipDeleteInfo(){m_pHeader = NULL; m_bDelete = false;}
CZipDeleteInfo(CZipFileHeader* pHeader, bool bDelete)
:m_pHeader(pHeader), m_bDelete (bDelete){}
CZipFileHeader* m_pHeader;
bool m_bDelete;
};
/**
Storage for callback functors. A structure for the internal use only.
\see SetCallback
*/
struct ZIP_API CZipClbckStrg : public CZipMap<CallbackType, CZipActionCallback*>
{
void Set(CZipActionCallback* pCallback, CallbackType iType)
{
if (pCallback)
{
SetAt(iType, pCallback);
}
else
RemoveKey(iType);
}
CZipActionCallback* Get(CallbackType i
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -