optimize GetExtension

This commit is contained in:
Glenn Maynard
2003-10-22 05:49:26 +00:00
parent da14c54268
commit 2715b39ba3
+9 -4
View File
@@ -317,10 +317,15 @@ CString SetExtension( const CString &path, const CString &ext )
CString GetExtension( CString sPath ) CString GetExtension( CString sPath )
{ {
CString Dir, FName, Ext; unsigned pos = sPath.rfind( '.' );
splitrelpath( sPath, Dir, FName, Ext ); if( pos == sPath.npos )
Ext.MakeLower(); return "";
return Ext;
unsigned slash = sPath.find( '/', slash );
if( slash != sPath.npos )
return ""; /* rare: path/dir.ext/fn */
return sPath.substr( pos+1, sPath.size()-pos+1 );
} }
CString GetCwd() CString GetCwd()