mirror of
https://github.com/transmission/transmission
synced 2025-02-02 20:43:51 +00:00
fix tr_mkdirp()'s errno/retvals.
This commit is contained in:
parent
2247a2d1f9
commit
dd75a769c9
2 changed files with 26 additions and 10 deletions
|
@ -439,12 +439,12 @@ tr_mkdirp( const char * path_in, int permissions )
|
|||
if( stat( path, &sb ) )
|
||||
{
|
||||
/* Folder doesn't exist yet */
|
||||
if( tr_mkdir( path, permissions ) )
|
||||
{
|
||||
tr_err( "Could not create directory %s (%s)", path,
|
||||
strerror( errno ) );
|
||||
if( tr_mkdir( path, permissions ) ) {
|
||||
const int err = errno;
|
||||
tr_err( "Couldn't create directory %s (%s)", path, strerror( err ) );
|
||||
tr_free( path );
|
||||
return 1;
|
||||
errno = err;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if( ( sb.st_mode & S_IFMT ) != S_IFDIR )
|
||||
|
@ -452,7 +452,8 @@ tr_mkdirp( const char * path_in, int permissions )
|
|||
/* Node exists but isn't a folder */
|
||||
tr_err( "Remove %s, it's in the way.", path );
|
||||
tr_free( path );
|
||||
return 1;
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( done )
|
||||
|
@ -507,7 +508,7 @@ tr_ioErrorFromErrno( void )
|
|||
}
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
tr_errorString( int code )
|
||||
{
|
||||
switch( code )
|
||||
|
|
|
@ -40,11 +40,26 @@ FILE* tr_getLog( void );
|
|||
|
||||
char* tr_getLogTimeStr( char * buf, int buflen );
|
||||
|
||||
int tr_rand ( int );
|
||||
/** Returns a random number in the range of [0...n) */
|
||||
int tr_rand ( int n );
|
||||
|
||||
/**
|
||||
* a portability wrapper around mkdir().
|
||||
* On WIN32, the `permissions' argument is unused.
|
||||
*
|
||||
* @return zero on success, or -1 if an error occurred
|
||||
* (in which case errno is set appropriately).
|
||||
*/
|
||||
int tr_mkdir( const char * path, int permissions );
|
||||
|
||||
/**
|
||||
* Like mkdir, but makes parent directories as needed.
|
||||
*
|
||||
* @return zero on success, or -1 if an error occurred
|
||||
* (in which case errno is set appropriately).
|
||||
*/
|
||||
int tr_mkdirp( const char * path, int permissions );
|
||||
|
||||
int tr_mkdir( const char * path, int permissions );
|
||||
|
||||
uint8_t* tr_loadFile( const char * filename, size_t * size );
|
||||
|
||||
|
@ -63,7 +78,7 @@ struct timeval timevalMsec( uint64_t milliseconds );
|
|||
|
||||
int tr_ioErrorFromErrno( void );
|
||||
|
||||
char * tr_errorString( int code );
|
||||
const char * tr_errorString( int code );
|
||||
|
||||
/* return the current date in milliseconds */
|
||||
uint64_t tr_date( void );
|
||||
|
|
Loading…
Reference in a new issue