00001
00002
00003
00004
00006
00007
00008
00009
00010
00011
00012
00013
00014
00016
00022 #if !defined(AFX_ZIPPATHCOMPONENT_H__9B222C08_AD11_4138_96CC_1237511E3E37__INCLUDED_)
00023 #define AFX_ZIPPATHCOMPONENT_H__9B222C08_AD11_4138_96CC_1237511E3E37__INCLUDED_
00024
00025 #if _MSC_VER > 1000
00026 #pragma once
00027 #endif // _MSC_VER > 1000
00028 #include "ZipString.h"
00029 #include "ZipExport.h"
00030
00034 class ZIP_API CZipPathComponent
00035 {
00036 public:
00037 CZipPathComponent(){}
00038 virtual ~CZipPathComponent();
00039
00040 static const TCHAR m_cSeparator;
00041
00044 static void AppendSeparator(CZipString& szPath)
00045 {
00046 RemoveSeparators(szPath);
00047 szPath += m_cSeparator;
00048 }
00049
00053 static void RemoveSeparators(CZipString& szPath)
00054 {
00055
00056 szPath.TrimRight(_T("\\/"));
00057 }
00058
00064 static void RemoveSeparatorsLeft(CZipString& szPath)
00065 {
00066 szPath.TrimLeft(_T("\\/"));
00067 }
00068
00069
00076 static bool IsSeparator(TCHAR c)
00077 {
00078 return c == _T('\\') || c == _T('/');
00079 }
00080
00084 static bool HasEndingSeparator(const CZipString& szPath)
00085 {
00086 int iLen = szPath.GetLength();
00087 if (iLen)
00088 return IsSeparator(szPath[iLen - 1]);
00089 else
00090 return false;
00091 }
00092
00099 CZipPathComponent(LPCTSTR lpszFullPath)
00100 {
00101 SetFullPath(lpszFullPath);
00102 }
00103
00104
00111 void SetFullPath(LPCTSTR lpszFullPath);
00112
00116 CZipString GetFileTitle() const { return m_szFileTitle;}
00117
00124 void SetFileTitle(LPCTSTR lpszFileTitle) { m_szFileTitle = lpszFileTitle;}
00125
00126
00132 void SetExtension(LPCTSTR lpszExt)
00133 {
00134 m_szFileExt = lpszExt;
00135 m_szFileExt.TrimLeft(_T('.'));
00136 }
00137
00141 CZipString GetFileExt() const { return m_szFileExt;}
00145 CZipString GetFileDrive() const { return m_szDrive;}
00149 CZipString GetNoDrive() const ;
00150
00154 CZipString GetFileName() const
00155 {
00156 CZipString szFullFileName = m_szFileTitle;
00157 if (!m_szFileExt.IsEmpty())
00158 {
00159 szFullFileName += _T(".");
00160 szFullFileName += m_szFileExt;
00161 }
00162 return szFullFileName;
00163 }
00167 CZipString GetFullPath() const
00168 {
00169 CZipString szFullPath = GetFilePath();
00170 CZipString szFileName = GetFileName();
00171 if (!szFileName.IsEmpty())
00172 {
00173 szFullPath += m_cSeparator;
00174 szFullPath += szFileName;
00175 }
00176 return szFullPath;
00177
00178 }
00182 CZipString GetFilePath() const
00183 {
00184 CZipString szDrive = m_szDrive;
00185 CZipString szDir = m_szDirectory;
00186 if (!szDrive.IsEmpty() && !szDir.IsEmpty())
00187 szDrive += m_cSeparator;
00188
00189 return m_szPrefix + szDrive + szDir;
00190
00191 }
00192 protected:
00197 CZipString m_szDirectory,
00198 m_szFileTitle,
00199 m_szFileExt,
00200 m_szDrive,
00201 m_szPrefix;
00202
00203
00204 };
00205
00206 #endif // !defined(AFX_ZIPPATHCOMPONENT_H__9B222C08_AD11_4138_96CC_1237511E3E37__INCLUDED_)