00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00014
00020 #if !defined(ZIPARCHIVE_ZIPPATHCOMPONENT_DOT_H)
00021 #define ZIPARCHIVE_ZIPPATHCOMPONENT_DOT_H
00022
00023 #if _MSC_VER > 1000
00024 #pragma once
00025 #if defined ZIP_HAS_DLL
00026 #pragma warning (push)
00027 #pragma warning( disable : 4251 ) // needs to have dll-interface to be used by clients of class
00028 #endif
00029 #endif
00030
00031 #include "ZipString.h"
00032 #include "ZipExport.h"
00033
00037 class ZIP_API CZipPathComponent
00038 {
00039
00040 public:
00041 static const CZipString PathPrefix;
00042 #ifdef _ZIP_SYSTEM_WIN
00043
00046 enum PrefixType
00047 {
00048 ptNone = 0,
00049 ptUnc = 2,
00050 ptUnicode = 4,
00051 ptUncWin = 8
00052 };
00062 static int IsPrefixed(const CZipString& path);
00063 #endif
00064 CZipPathComponent(){}
00074 CZipPathComponent(LPCTSTR lpszFullPath)
00075 {
00076 SetFullPath(lpszFullPath);
00077 }
00078
00079 virtual ~CZipPathComponent();
00080
00081 static const TCHAR m_cSeparator;
00082
00089 static void AppendSeparator(CZipString& szPath)
00090 {
00091 RemoveSeparators(szPath);
00092 szPath += m_cSeparator;
00093 }
00094
00104 static void Combine(CZipString& szPath, LPCTSTR lpszName)
00105 {
00106 AppendSeparator(szPath);
00107 if (lpszName != NULL)
00108 szPath += lpszName;
00109 }
00110
00117 static void RemoveSeparators(CZipString& szPath)
00118 {
00119
00120 szPath.TrimRight(_T("\\/"));
00121 }
00122
00129 static void RemoveSeparatorsLeft(CZipString& szPath)
00130 {
00131 szPath.TrimLeft(_T("\\/"));
00132 }
00133
00134
00144 static bool IsSeparator(TCHAR c)
00145 {
00146 return c == _T('\\') || c == _T('/');
00147 }
00148
00158 static bool HasEndingSeparator(const CZipString& szPath)
00159 {
00160 int iLen = szPath.GetLength();
00161 if (iLen)
00162 return IsSeparator(szPath[iLen - 1]);
00163 else
00164 return false;
00165 }
00166
00174 void SetFullPath(LPCTSTR lpszFullPath);
00175
00182 CZipString GetFileTitle() const { return m_szFileTitle;}
00183
00190 void SetFileTitle(LPCTSTR lpszFileTitle) { m_szFileTitle = lpszFileTitle;}
00191
00192
00199 void SetExtension(LPCTSTR lpszExt)
00200 {
00201 m_szFileExt = lpszExt;
00202 m_szFileExt.TrimLeft(_T('.'));
00203 }
00204
00211 CZipString GetFileExt() const { return m_szFileExt;}
00212
00219 CZipString GetFileDrive() const { return m_szDrive;}
00220
00227 CZipString GetNoDrive() const ;
00228
00235 CZipString GetFileName() const
00236 {
00237 CZipString szFullFileName = m_szFileTitle;
00238 if (!m_szFileExt.IsEmpty())
00239 {
00240 szFullFileName += _T(".");
00241 szFullFileName += m_szFileExt;
00242 }
00243 return szFullFileName;
00244 }
00245
00252 CZipString GetFullPath() const
00253 {
00254 CZipString szFullPath = GetFilePath();
00255 CZipString szFileName = GetFileName();
00256 if (!szFileName.IsEmpty())
00257 {
00258 if (szFullPath.IsEmpty())
00259 szFullPath += _T('.');
00260 szFullPath += m_cSeparator;
00261 szFullPath += szFileName;
00262 }
00263 return szFullPath;
00264 }
00265
00272 CZipString GetFilePath() const
00273 {
00274 CZipString szDrive = m_szDrive;
00275 CZipString szDir = m_szDirectory;
00276 if (!szDrive.IsEmpty() && !szDir.IsEmpty())
00277 szDrive += m_cSeparator;
00278
00279 return m_szPrefix + szDrive + szDir;
00280 }
00281 protected:
00286 CZipString m_szDirectory,
00287 m_szFileTitle,
00288 m_szFileExt,
00289 m_szDrive,
00290 m_szPrefix;
00291
00292
00293 };
00294
00295 #if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL)
00296 #pragma warning (pop)
00297 #endif
00298
00299
00300 #endif // !defined(ZIPARCHIVE_ZIPPATHCOMPONENT_DOT_H)