mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-20 12:00:47 +00:00
utils: mdldec: try to create user defined destination directory.
This commit is contained in:
parent
8211acf4e0
commit
cbcb90638b
@ -164,9 +164,9 @@ static qboolean LoadMDL( const char *modelname )
|
||||
|
||||
if( destdir[0] != '\0' )
|
||||
{
|
||||
if( !IsFileExists( destdir ) )
|
||||
if( !MakeDirectory( destdir ) )
|
||||
{
|
||||
fprintf( stderr, "ERROR: Couldn't find directory %s\n", destdir );
|
||||
fprintf( stderr, "ERROR: Couldn't create directory %s\n", destdir );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ static qboolean LoadMDL( const char *modelname )
|
||||
else
|
||||
COM_ExtractFilePath( modelname, destdir );
|
||||
|
||||
len -= 4; // path length without extension
|
||||
len -= ( sizeof( ".mdl" ) - 1 ); // path length without extension
|
||||
|
||||
if( !model_hdr->numtextures )
|
||||
{
|
||||
|
@ -18,22 +18,22 @@ GNU General Public License for more details.
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include "xash3d_types.h"
|
||||
#include "port.h"
|
||||
#include "crtlib.h"
|
||||
#include "utils.h"
|
||||
|
||||
/*
|
||||
============
|
||||
IsFileExists
|
||||
MakeDirectory
|
||||
============
|
||||
*/
|
||||
qboolean IsFileExists( const char *filename )
|
||||
qboolean MakeDirectory( const char *path )
|
||||
{
|
||||
struct stat st;
|
||||
int ret;
|
||||
|
||||
ret = stat( filename, &st );
|
||||
|
||||
if( ret == -1 )
|
||||
if( -1 == _mkdir( path )
|
||||
&& ( -1 == stat( path, &st )
|
||||
|| !S_ISDIR(st.st_mode ) ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -44,7 +44,7 @@ qboolean IsFileExists( const char *filename )
|
||||
GetFileSize
|
||||
============
|
||||
*/
|
||||
off_t GetFileSize( FILE *fp )
|
||||
off_t GetSizeOfFile( FILE *fp )
|
||||
{
|
||||
struct stat st;
|
||||
int fd;
|
||||
@ -71,7 +71,7 @@ byte *LoadFile( const char *filename )
|
||||
if( !fp )
|
||||
return NULL;
|
||||
|
||||
size = GetFileSize( fp );
|
||||
size = GetSizeOfFile( fp );
|
||||
|
||||
buf = malloc( size );
|
||||
|
||||
|
@ -16,8 +16,8 @@ GNU General Public License for more details.
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
qboolean IsFileExists( const char *filename );
|
||||
off_t GetFileSize( FILE *fp );
|
||||
qboolean MakeDirectory( const char *path );
|
||||
off_t GetSizeOfFile( FILE *fp );
|
||||
byte *LoadFile( const char *filename );
|
||||
|
||||
#endif // UTILS_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user