diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2021-09-04 19:21:59 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2021-09-04 19:21:59 -0700 |
commit | e7a029d73fbce3145063f0e65b952b356014cf63 (patch) | |
tree | 5af31da61093df0d66b455f2d775b3001cdda7c2 /src/misc/extra/extraUtilFile.c | |
parent | ed9c16d4f5e1484bb287c30a6af50832a62d35ec (diff) | |
download | abc-e7a029d73fbce3145063f0e65b952b356014cf63.tar.gz abc-e7a029d73fbce3145063f0e65b952b356014cf63.tar.bz2 abc-e7a029d73fbce3145063f0e65b952b356014cf63.zip |
Various changes.
Diffstat (limited to 'src/misc/extra/extraUtilFile.c')
-rw-r--r-- | src/misc/extra/extraUtilFile.c | 13 |
1 files changed, 8 insertions, 5 deletions
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 ) |