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 ) @@ -351,12 +351,9 @@ 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 );

34
utils/mdldec/utils.c

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

1
utils/mdldec/utils.h

@ -17,6 +17,7 @@ GNU General Public License for more details. @@ -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 );

Loading…
Cancel
Save