OSDN Git Service

Added (temporarily) two missing functions: GetPathOnly and SplitFilename.
authorChris Mumford <cmumford@users.sourceforge.net>
Sun, 9 Feb 2003 14:50:19 +0000 (14:50 +0000)
committerChris Mumford <cmumford@users.sourceforge.net>
Sun, 9 Feb 2003 14:50:19 +0000 (14:50 +0000)
Src/DirDoc.cpp
Src/StdAfx.h

index 2cef007..ccb4e63 100644 (file)
@@ -398,6 +398,66 @@ void CDirDoc::SetDiffContext(CDiffContext *pCtxt)
        m_pCtxt = pCtxt;
 }
 
+
+
+CString GetPathOnly( const CString& sString )
+{
+       int nIdx = sString.GetLength();
+
+       CString sReturn;
+
+       while ( nIdx-- ) {
+
+               if ( sString.GetAt(nIdx) == '/' || sString.GetAt(nIdx) == '\\' ) {
+                       if ( nIdx > 1 ) {
+                               char* pszRet = sReturn.GetBufferSetLength( nIdx );
+                               strncpy( pszRet, sString, nIdx );
+                               pszRet[nIdx] = '\0';
+                               sReturn.ReleaseBuffer();
+                       }
+               }
+       }
+
+       return sReturn;
+}
+
+
+//
+// extension does not have '.'
+//
+void SplitFilename( LPCTSTR pathLeft, CString* pPath, CString* pFile, CString* pExt )
+{
+       const TCHAR* pszChar = pathLeft + strlen(pathLeft);
+
+       while ( pathLeft < --pszChar ) {
+               if ( *pszChar == '.' && pExt != NULL && pExt->GetLength() == 0 ) {
+                       
+                       *pExt = pszChar + 1;
+               }
+               else if ( *pszChar == '/' || *pszChar == '\\' ) {
+                       
+                       // Set the directory
+                       if ( pPath != NULL ) {
+                               char* pszDir = pPath->GetBufferSetLength( pszChar - pathLeft );
+                               strncpy( pszDir, pathLeft, pszChar - pathLeft );
+                               pszDir[pszChar - pathLeft] = '\0';
+                               pPath->ReleaseBuffer();
+                       }
+
+                       // Set the file
+                       if ( pFile != NULL ) {
+                               *pFile = pszChar + 1;
+                       }
+
+                       return;
+               }
+       }
+
+       // Never found a delimiter
+}
+
+
+
 BOOL CDirDoc::UpdateItemStatus(LPCTSTR pathLeft, LPCTSTR pathRight,
                                                           UINT status)
 {
index e847959..e0ffcae 100644 (file)
@@ -36,6 +36,12 @@ int xisalpha (int c);
 int xisalnum (int c);
 
 #include "edtlib.h"
+
+CString GetPathOnly( const CString& sString );
+void SplitFilename( LPCTSTR pathLeft, CString* pPath, CString* pFile, CString* pExt );
+
+
+
 //{{AFX_INSERT_LOCATION}}
 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.