//--------------------------------------------------------------------------- MyString MYRTLEXP GetFExtOnly( const MyString& nm, char Slash ) { char *m = StrRChr( nm.Text(),Slash ); if ( !m ) m = nm.Text(); m = StrRChr( m,'.' ); if (m) return MyString(m+1); else return MyString(""); }
CONSTSTR MYRTLEXP StrDelStr( CONSTSTR str,CONSTSTR subStr,int pos ) { CONSTSTR m = (str && subStr)?strstr(str+Min(pos,(int)strLen(str)),subStr):NULL; resStrSCol = ""; if ( !m ) { if (str) resStrSCol = str; return resStrSCol.Text(); } for ( ; *str && str != m; str++ ) resStrSCol.Add(*str); for ( ; *str && *subStr; subStr++,str++ ); for ( ; *str; str++ ) resStrSCol.Add(*str); return resStrSCol.Text(); }
MyString MYRTLEXP GetFNameOnly( const MyString& nm, char Slash ) { char str[ MAX_PATH_SIZE ]; char *m = StrRChr( nm.Text(),Slash ); if (!m) m = nm.Text(); else m++; StrCpy( str,m,sizeof(str) ); m = StrRChr(str,'.'); if (m) *m = 0; return MyString(str); }
//--------------------------------------------------------------------------- MyString MYRTLEXP GetFName( const MyString& nm, char Slash ) { char *m = StrRChr( nm.Text(), Slash ); if (!m) return MyString(nm); else return MyString(m+1); }
//--------------------------------------------------------------------------- MyString MYRTLEXP GetFPath( const MyString& nm, char Slash ) { char str[ MAX_PATH_SIZE ]; char *m; StrCpy( str,nm.Text(),sizeof(str) ); m = StrRChr( str,Slash ); if (m) *m = 0; else str[0] = 0; return MyString( AddLastSlash(str) ); }
CONSTSTR MYRTLEXP StrGetCol( MyString& buff, CONSTSTR str,int number,CONSTSTR seps ) { int res; for ( res = 1; *str && res < number; str++ ) if ( StrChr(seps,*str) != NULL ) res++; buff = ""; if ( res == number ) for( ; *str && StrChr(seps,*str) == NULL; str++ ) buff.Add(*str); return buff.Text(); }
MyString MYRTLEXP MakeFullPathName( const MyString& fname, const MyString& base ) { MyString oldP,s; if ( fname.Chr(SLASH_CHAR) == -1 ) { s.Set( base ); s.Add( SLASH_CHAR ); s.Add( fname ); return s; } oldP = GetCurDir(); //Go base path SetCurDir( base.Text() ); //Go fname path in case it relative SetCurDir( FPath(fname.Text()) ); //Get result path + name s.Set( GetCurDir() ); s.Add( FName(fname.Text()) ); SetCurDir( oldP.Text() ); return s; }
BOOL MYRTLEXP PathCmp( const MyString& path,const MyString& path1 ) { return CMP_FILE( path.Text(),path1.Text() ); }
/*************************************** Procedures ***************************************/ BOOL MYRTLEXP BasePath( const MyString& base, const MyString& path ) { return path.Length() >= base.Length() && CMPN_FILE( path.Text(),base.Text(),base.Length() ); }