mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2025-01-09 11:30:51 +00:00
Adjusting vfswad filename extraction
This commit is contained in:
parent
3bc866b623
commit
3f13802fe4
1 changed files with 30 additions and 6 deletions
|
@ -145,13 +145,36 @@ int vfsBuildShortPathName( const char* pPath, char* pBuffer, int nBufferLen ){
|
|||
#endif
|
||||
}
|
||||
|
||||
void ExtractFileName( const char *path, char *dest ){
|
||||
const char *src;
|
||||
|
||||
src = path + strlen( path ) - 1;
|
||||
|
||||
//
|
||||
// back up until a \ or the start
|
||||
//
|
||||
while ( src != path && *( src - 1 ) != '/'
|
||||
&& *( src - 1 ) != '\\' )
|
||||
src--;
|
||||
|
||||
while ( *src )
|
||||
{
|
||||
*dest++ = *src++;
|
||||
}
|
||||
*dest = 0;
|
||||
}
|
||||
|
||||
static void vfsInitPakFile( const char *filename ){
|
||||
wadFile_t *wf;
|
||||
unsigned int i;
|
||||
int err;
|
||||
char *wadnameptr;
|
||||
char wadname[NAME_MAX];
|
||||
char *ext;
|
||||
|
||||
if ( !filename || strlen( filename ) <= 0 ) {
|
||||
g_FuncTable.m_pfnSysFPrintf( SYS_WRN, " missing wad filename\n" );
|
||||
return;
|
||||
}
|
||||
wf = wadOpen( filename );
|
||||
if ( wf == NULL ) {
|
||||
g_FuncTable.m_pfnSysFPrintf( SYS_WRN, " failed to init wad file %s\n", filename );
|
||||
|
@ -159,13 +182,14 @@ static void vfsInitPakFile( const char *filename ){
|
|||
}
|
||||
g_FuncTable.m_pfnSysPrintf( " wad file: %s\n", filename );
|
||||
|
||||
for ( i = strlen( filename ) - 1 ; i >= 0 && filename[i] != '\\' && filename[i] != '/' ; i-- )
|
||||
wadnameptr = (char *)filename + i;
|
||||
|
||||
strcpy( wadname,wadnameptr );
|
||||
wadname[strlen( wadname ) - 4] = 0; // ditch the .wad so everthing looks nice!
|
||||
ExtractFileName( filename, wadname );
|
||||
strlwr( wadname );
|
||||
|
||||
ext = strrchr( wadname, '.' );
|
||||
if ( ext && strcmp( ext, ".wad" ) == 0 ) {
|
||||
*ext = 0; // ditch the .wad so everthing looks nice!
|
||||
}
|
||||
|
||||
g_wadFiles = g_slist_append( g_wadFiles, wf ); // store the wadfile handle
|
||||
|
||||
wadGoToFirstFile( wf );
|
||||
|
|
Loading…
Reference in a new issue