Browse Source

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

pull/2/head
Andrey Akhmichin 1 year ago committed by Alibek Omarov
parent
commit
f9b6389248
  1. 5
      utils/mdldec/mdldec.c
  2. 34
      utils/mdldec/utils.c
  3. 1
      utils/mdldec/utils.h

5
utils/mdldec/mdldec.c

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

34
utils/mdldec/utils.c

@ -54,6 +54,40 @@ qboolean MakeDirectory( const char *path )
return true; 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 ExtractFileName

1
utils/mdldec/utils.h

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

Loading…
Cancel
Save