#include "..\stdafx.h" #include "TGData.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif //////////////////////////////////////////////////////////////////////////////// // ·¾¶ //////////////////////////////////////////////////////////////////////////////// TGPath::TGPath(const TCHAR *pszName) { m_strPath = pszName; } TGPath::~TGPath() { } void TGPath::GetName(CString &strName)const { int i = m_strPath.ReverseFind(_T('\\')); if (i == NOT_FOUND) strName = m_strPath; else { if (m_strPath.GetLength() <= i + 1) strName = _T(""); else strName = m_strPath.Right(m_strPath.GetLength()-i-1); } } bool TGPath::GetTopCat(CString &strName)const { int i = m_strPath.Find(_T('\\')); if (i == NOT_FOUND) return false; else { strName = m_strPath.Left(i); return true; } } bool TGPath::GetLowPath(TGPath&path)const { int i = m_strPath.Find(_T('\\')); if (i == NOT_FOUND) return false; else { if (m_strPath.GetLength()-i-1 > 0) path = m_strPath.Right(m_strPath.GetLength()-i-1); return true; } } void TGPath::Resolve(TPDList&lstStrCats)const { int from = 0; int to; while (from < m_strPath.GetLength() && (to = m_strPath.Find(_T('\\'), from)) != NOT_FOUND) { if (to == from) lstStrCats<IsRoot()) strName = m_sName; else { CString temp; GetParent()->GeTGPathName(temp); strName = temp+_T("\\") + m_sName; } }