* contrib/hbziparch/_features.h
* contrib/hbziparch/_platform.h
* contrib/hbziparch/Aes.cpp
* contrib/hbziparch/Aes.h
* contrib/hbziparch/BaseLibCompressor.cpp
* contrib/hbziparch/BaseLibCompressor.h
* contrib/hbziparch/BytesWriter.h
* contrib/hbziparch/Bzip2Compressor.cpp
* contrib/hbziparch/Bzip2Compressor.h
* contrib/hbziparch/DeflateCompressor.cpp
* contrib/hbziparch/DeflateCompressor.h
* contrib/hbziparch/DirEnumerator.cpp
* contrib/hbziparch/DirEnumerator.h
* contrib/hbziparch/FileFilter.cpp
* contrib/hbziparch/FileFilter.h
* contrib/hbziparch/FileInfo.h
* contrib/hbziparch/Hmac.cpp
* contrib/hbziparch/Hmac.h
* contrib/hbziparch/RandomPool.cpp
* contrib/hbziparch/RandomPool.h
* contrib/hbziparch/Sha1.cpp
* contrib/hbziparch/Sha1.h
* contrib/hbziparch/std_mfc.h
* contrib/hbziparch/std_stl.h
* contrib/hbziparch/Wildcard.cpp
* contrib/hbziparch/Wildcard.h
* contrib/hbziparch/ZipAbstractFile.h
* contrib/hbziparch/ZipAesCryptograph.cpp
* contrib/hbziparch/ZipAesCryptograph.h
* contrib/hbziparch/ZipArchive.cpp
* contrib/hbziparch/ZipArchive.h
* contrib/hbziparch/ZipAutoBuffer.cpp
* contrib/hbziparch/ZipAutoBuffer.h
* contrib/hbziparch/ZipBaseException.h
* contrib/hbziparch/ZipCallback.h
* contrib/hbziparch/ZipCallbackProvider.h
* contrib/hbziparch/ZipCentralDir.cpp
* contrib/hbziparch/ZipCentralDir.h
* contrib/hbziparch/ZipCollections.h
* contrib/hbziparch/ZipCollections_mfc.h
* contrib/hbziparch/ZipCollections_stl.h
* contrib/hbziparch/ZipCompatibility.cpp
* contrib/hbziparch/ZipCompatibility.h
* contrib/hbziparch/ZipCompressor.cpp
* contrib/hbziparch/ZipCompressor.h
* contrib/hbziparch/ZipCrc32Cryptograph.cpp
* contrib/hbziparch/ZipCrc32Cryptograph.h
* contrib/hbziparch/ZipCryptograph.cpp
* contrib/hbziparch/ZipCryptograph.h
* contrib/hbziparch/ZipException.cpp
* contrib/hbziparch/ZipException.h
* contrib/hbziparch/ZipExtraData.cpp
* contrib/hbziparch/ZipExtraData.h
* contrib/hbziparch/ZipExtraField.cpp
* contrib/hbziparch/ZipExtraField.h
* contrib/hbziparch/ZipFile.h
* contrib/hbziparch/ZipFile_mfc.cpp
* contrib/hbziparch/ZipFile_mfc.h
* contrib/hbziparch/ZipFile_stl.cpp
* contrib/hbziparch/ZipFile_stl.h
* contrib/hbziparch/ZipFileHeader.cpp
* contrib/hbziparch/ZipFileHeader.h
* contrib/hbziparch/ZipFileMapping.h
* contrib/hbziparch/ZipFileMapping_lnx.h
* contrib/hbziparch/ZipFileMapping_win.h
* contrib/hbziparch/ZipMemFile.cpp
* contrib/hbziparch/ZipMemFile.h
* contrib/hbziparch/ZipMutex.h
* contrib/hbziparch/ZipMutex_lnx.h
* contrib/hbziparch/ZipMutex_win.h
* contrib/hbziparch/ZipPathComponent.h
* contrib/hbziparch/ZipPlatform.h
* contrib/hbziparch/ZipPlatformComm.cpp
* contrib/hbziparch/ZipStorage.cpp
* contrib/hbziparch/ZipStorage.h
* contrib/hbziparch/ZipString.h
* contrib/hbziparch/ZipString_mfc.h
* contrib/hbziparch/ZipString_stl.h
* contrib/hbziparch/ZipStringStoreSettings.h
+ ZipArchive lib update finished.
; Pass 2/2
; Please test.
277 lines
6.1 KiB
C++
277 lines
6.1 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// This source file is part of the ZipArchive library source distribution and
|
|
// is Copyrighted 2000 - 2007 by Artpol Software - Tadeusz Dracz
|
|
//
|
|
// This program is free software; you can redistribute it and/or
|
|
// modify it under the terms of the GNU General Public License
|
|
// as published by the Free Software Foundation; either version 2
|
|
// of the License, or (at your option) any later version.
|
|
//
|
|
// For the licensing details refer to the License.txt file.
|
|
//
|
|
// Web Site: http://www.artpol-software.com
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
* \file ZipPathComponent.h
|
|
* Includes the CZipPathComponent class.
|
|
*
|
|
*/
|
|
#if !defined(ZIPARCHIVE_ZIPPATHCOMPONENT_DOT_H)
|
|
#define ZIPARCHIVE_ZIPPATHCOMPONENT_DOT_H
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#if defined ZIP_HAS_DLL
|
|
#pragma warning (push)
|
|
#pragma warning( disable : 4251 ) // needs to have dll-interface to be used by clients of class
|
|
#endif
|
|
#endif
|
|
|
|
#include "ZipString.h"
|
|
#include "ZipExport.h"
|
|
|
|
/**
|
|
Splits a file path into components.
|
|
*/
|
|
class ZIP_API CZipPathComponent
|
|
{
|
|
public:
|
|
CZipPathComponent(){}
|
|
virtual ~CZipPathComponent();
|
|
|
|
static const TCHAR m_cSeparator; ///< A system - specific default path separator.
|
|
|
|
/**
|
|
Appends a path separator to \a szPath, if it is not already appended.
|
|
|
|
\param szPath
|
|
The path to have a separator appended.
|
|
*/
|
|
static void AppendSeparator(CZipString& szPath)
|
|
{
|
|
RemoveSeparators(szPath);
|
|
szPath += m_cSeparator;
|
|
}
|
|
|
|
/**
|
|
Combines a path information with a file name information.
|
|
|
|
\param szPath
|
|
Provides the path information and retrieves the result.
|
|
|
|
\param lpszName
|
|
The filename to be appended to the path.
|
|
*/
|
|
static void Combine(CZipString& szPath, LPCTSTR lpszName)
|
|
{
|
|
AppendSeparator(szPath);
|
|
if (lpszName != NULL)
|
|
szPath += lpszName;
|
|
}
|
|
|
|
/**
|
|
Removes path separators from the end of \a szPath
|
|
|
|
\param szPath
|
|
The path to have path separators removed.
|
|
*/
|
|
static void RemoveSeparators(CZipString& szPath)
|
|
{
|
|
// szPath.TrimRight(m_cSeparator);
|
|
szPath.TrimRight(_T("\\/"));
|
|
}
|
|
|
|
/**
|
|
Removes path separators from the beginning of \a szPath.
|
|
|
|
\param szPath
|
|
The path to have path separators removed.
|
|
*/
|
|
static void RemoveSeparatorsLeft(CZipString& szPath)
|
|
{
|
|
szPath.TrimLeft(_T("\\/"));
|
|
}
|
|
|
|
|
|
/**
|
|
Tests the character, if it is a separator or not.
|
|
|
|
\param c
|
|
The character to test.
|
|
|
|
\return
|
|
\c true, if \a c is a path separator; \c false otherwise.
|
|
*/
|
|
static bool IsSeparator(TCHAR c)
|
|
{
|
|
return c == _T('\\') || c == _T('/');
|
|
}
|
|
|
|
/**
|
|
Checks if \a szPath has a path separator appended.
|
|
|
|
\param szPath
|
|
The path to be tested.
|
|
|
|
\return
|
|
\c true, if \a szPath has a path separator at the end; \c false otherwise.
|
|
*/
|
|
static bool HasEndingSeparator(const CZipString& szPath)
|
|
{
|
|
int iLen = szPath.GetLength();
|
|
if (iLen)
|
|
return IsSeparator(szPath[iLen - 1]);
|
|
else
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
Initializes a new instance of the CZipPathComponent class.
|
|
|
|
\param lpszFullPath
|
|
The full path to the file.
|
|
|
|
\see
|
|
SetFullPath
|
|
*/
|
|
CZipPathComponent(LPCTSTR lpszFullPath)
|
|
{
|
|
SetFullPath(lpszFullPath);
|
|
}
|
|
|
|
/**
|
|
Sets the full path to the file.
|
|
|
|
\param lpszFullPath
|
|
The full path to the file including a filename.
|
|
The last element in the path is assumed to be a filename.
|
|
*/
|
|
void SetFullPath(LPCTSTR lpszFullPath);
|
|
|
|
/**
|
|
Gets the name of the file without an extension (and without a path).
|
|
|
|
\return
|
|
The title of the file.
|
|
*/
|
|
CZipString GetFileTitle() const { return m_szFileTitle;}
|
|
|
|
/**
|
|
Sets the file title (the name without an extension and without a path).
|
|
|
|
\param lpszFileTitle
|
|
The title to set.
|
|
*/
|
|
void SetFileTitle(LPCTSTR lpszFileTitle) { m_szFileTitle = lpszFileTitle;}
|
|
|
|
|
|
/**
|
|
Sets the extension alone.
|
|
|
|
\param lpszExt
|
|
The extension to set. May contain a dot at the beginning, but doesn't have to.
|
|
*/
|
|
void SetExtension(LPCTSTR lpszExt)
|
|
{
|
|
m_szFileExt = lpszExt;
|
|
m_szFileExt.TrimLeft(_T('.'));
|
|
}
|
|
|
|
/**
|
|
Gets the extension of the file.
|
|
|
|
\return
|
|
The extension without a dot.
|
|
*/
|
|
CZipString GetFileExt() const { return m_szFileExt;}
|
|
|
|
/**
|
|
Gets the drive of the file.
|
|
|
|
\return
|
|
The drive without a path separator at the end.
|
|
*/
|
|
CZipString GetFileDrive() const { return m_szDrive;}
|
|
|
|
/**
|
|
Gets the full path to the file without the drive.
|
|
|
|
\return
|
|
The path without the drive and without a path separator at the beginning.
|
|
*/
|
|
CZipString GetNoDrive() const ;
|
|
|
|
/**
|
|
Get the filename.
|
|
|
|
\return
|
|
The filename including an extension and without a path.
|
|
*/
|
|
CZipString GetFileName() const
|
|
{
|
|
CZipString szFullFileName = m_szFileTitle;
|
|
if (!m_szFileExt.IsEmpty())
|
|
{
|
|
szFullFileName += _T(".");
|
|
szFullFileName += m_szFileExt;
|
|
}
|
|
return szFullFileName;
|
|
}
|
|
|
|
/**
|
|
Gets the full path to the file.
|
|
|
|
\return
|
|
The full path information including the filename.
|
|
*/
|
|
CZipString GetFullPath() const
|
|
{
|
|
CZipString szFullPath = GetFilePath();
|
|
CZipString szFileName = GetFileName();
|
|
if (!szFileName.IsEmpty())
|
|
{
|
|
if (szFullPath.IsEmpty())
|
|
szFullPath += _T('.');
|
|
szFullPath += m_cSeparator;
|
|
szFullPath += szFileName;
|
|
}
|
|
return szFullPath;
|
|
}
|
|
|
|
/**
|
|
Gets the path part only.
|
|
|
|
\return
|
|
The path to the file without a filename and without a path separator at the end.
|
|
*/
|
|
CZipString GetFilePath() const
|
|
{
|
|
CZipString szDrive = m_szDrive;
|
|
CZipString szDir = m_szDirectory;
|
|
if (!szDrive.IsEmpty() && !szDir.IsEmpty())
|
|
szDrive += m_cSeparator;
|
|
|
|
return m_szPrefix + szDrive + szDir;
|
|
}
|
|
protected:
|
|
/**
|
|
\name Path parts.
|
|
*/
|
|
//@{
|
|
CZipString m_szDirectory, ///< A directory(ies) only without path separators at the end and the beginning.
|
|
m_szFileTitle, ///< A filename without an extension.
|
|
m_szFileExt, ///< A file extension without a dot.
|
|
m_szDrive, ///< A drive (if the system path standard uses it) without a path separator at the end.
|
|
m_szPrefix; ///< A prefix (e.g. for the UNC path or Unicode path under Windows).
|
|
//@}
|
|
|
|
};
|
|
|
|
#if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
|
|
#pragma warning (pop)
|
|
#endif
|
|
|
|
|
|
#endif // !defined(ZIPARCHIVE_ZIPPATHCOMPONENT_DOT_H)
|