utils: mdldec: create full destination path into "Kratisto's mdldec" maner.

This commit is contained in:
Andrey Akhmichin 2023-11-25 02:33:59 +05:00 committed by Alibek Omarov
parent 9ec1e259b4
commit f9b6389248
3 changed files with 36 additions and 4 deletions

View File

@ -351,11 +351,8 @@ static qboolean LoadMDL( const char *modelname )
if( destdir[0] != '\0' )
{
if( !MakeDirectory( destdir ))
{
fprintf( stderr, "ERROR: Couldn't create directory %s\n", destdir );
if( !MakeFullPath( destdir ))
return false;
}
}
else
COM_ExtractFilePath( modelname, destdir );

View File

@ -54,6 +54,40 @@ qboolean MakeDirectory( const char *path )
return true;
}
/*
============
MakeFullPath
============
*/
qboolean MakeFullPath( const char *path )
{
char *p = (char *)path, tmp;
for( ; *p; )
{
p = Q_strpbrk( p, "/\\" );
if( p )
{
tmp = *p;
*p = '\0';
}
if( !MakeDirectory( path ))
{
fprintf( stderr, "ERROR: Couldn't create directory %s\n", path );
return false;
}
if( !p )
break;
*p++ = tmp;
}
return true;
}
/*
============
ExtractFileName

View File

@ -17,6 +17,7 @@ GNU General Public License for more details.
#define UTILS_H
qboolean MakeDirectory( const char *path );
qboolean MakeFullPath( const char *path );
void ExtractFileName( char *name, size_t size );
off_t GetSizeOfFile( FILE *fp );
byte *LoadFile( const char *filename, off_t *size );