From e7a029d73fbce3145063f0e65b952b356014cf63 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 4 Sep 2021 19:21:59 -0700 Subject: Various changes. --- src/misc/extra/extraUtilFile.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/misc/extra') diff --git a/src/misc/extra/extraUtilFile.c b/src/misc/extra/extraUtilFile.c index 9d3a2ae4..54e6efc2 100644 --- a/src/misc/extra/extraUtilFile.c +++ b/src/misc/extra/extraUtilFile.c @@ -249,11 +249,14 @@ char * Extra_FilePathWithoutName( char * FileName ) } char * Extra_FileInTheSameDir( char * pPathFile, char * pFileName ) { - static char pBuffer[1000]; - char * pPath = Extra_FilePathWithoutName( pPathFile ); - assert( strlen(pPath) + strlen(pFileName) < 990 ); - sprintf( pBuffer, "%s%s", pPath, pFileName ); - ABC_FREE( pPath ); + static char pBuffer[1000]; char * pThis; + assert( strlen(pPathFile) + strlen(pFileName) < 990 ); + memmove( pBuffer, pPathFile, strlen(pPathFile) ); + for ( pThis = pBuffer + strlen(pPathFile) - 1; pThis >= pBuffer; pThis-- ) + if ( *pThis == '\\' || *pThis == '/' ) + break; + memmove( ++pThis, pFileName, strlen(pFileName) ); + pThis[strlen(pFileName)] = '\0'; return pBuffer; } char * Extra_FileDesignName( char * pFileName ) -- cgit v1.2.3