diff --git a/utils/mdldec/mdldec.c b/utils/mdldec/mdldec.c index 5cb5b8b1..05761d77 100644 --- a/utils/mdldec/mdldec.c +++ b/utils/mdldec/mdldec.c @@ -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 ); diff --git a/utils/mdldec/utils.c b/utils/mdldec/utils.c index 6b851738..21dcd9a1 100644 --- a/utils/mdldec/utils.c +++ b/utils/mdldec/utils.c @@ -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 diff --git a/utils/mdldec/utils.h b/utils/mdldec/utils.h index b0ddfe57..da6d2d2c 100644 --- a/utils/mdldec/utils.h +++ b/utils/mdldec/utils.h @@ -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 );