ZipPathComponent.h

Go to the documentation of this file.
00001 
00002 // $RCSfile: ZipPathComponent.h,v $
00003 // $Revision: 1.3 $
00004 // $Date: 2006/01/28 20:18:12 $ $Author: Tadeusz Dracz $
00006 // This source file is part of the ZipArchive library source distribution and
00007 // is Copyrighted 2000 - 2006 by Tadeusz Dracz (http://www.artpol-software.com/)
00008 //
00009 // This program is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 // 
00014 // For the licensing details see the file License.txt
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 //   szPath.TrimRight(m_cSeparator);
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  // full path of the file (not a directory alone)
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_)

ZipArchive Copyright © 2000 - 2006 Tadeusz Dracz . Generated at Fri Apr 7 13:55:23 2006.