Changeset 4733


Ignore:
Timestamp:
Jan 18, 2008, 1:40:41 AM (14 years ago)
Author:
charles
Message:

fix tr_mkdirp()'s errno/retvals.

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r4597 r4733  
    440440        {
    441441            /* Folder doesn't exist yet */
    442             if( tr_mkdir( path, permissions ) )
    443             {
    444                 tr_err( "Could not create directory %s (%s)", path,
    445                         strerror( errno ) );
     442            if( tr_mkdir( path, permissions ) ) {
     443                const int err = errno;
     444                tr_err( "Couldn't create directory %s (%s)", path, strerror( err ) );
    446445                tr_free( path );
    447                 return 1;
     446                errno = err;
     447                return -1;
    448448            }
    449449        }
     
    453453            tr_err( "Remove %s, it's in the way.", path );
    454454            tr_free( path );
    455             return 1;
     455            errno = ENOTDIR;
     456            return -1;
    456457        }
    457458
     
    508509}
    509510
    510 char *
     511const char *
    511512tr_errorString( int code )
    512513{
  • trunk/libtransmission/utils.h

    r4482 r4733  
    4141char* tr_getLogTimeStr( char * buf, int buflen );
    4242
    43 int tr_rand ( int );
     43/** Returns a random number in the range of [0...n) */
     44int tr_rand ( int n );
    4445
     46/**
     47 * a portability wrapper around mkdir().
     48 * On WIN32, the `permissions' argument is unused.
     49 *
     50 * @return zero on success, or -1 if an error occurred
     51 * (in which case errno is set appropriately).
     52 */
     53int tr_mkdir( const char * path, int permissions );
     54
     55/**
     56 * Like mkdir, but makes parent directories as needed.
     57 *
     58 * @return zero on success, or -1 if an error occurred
     59 * (in which case errno is set appropriately).
     60 */
    4561int tr_mkdirp( const char * path, int permissions );
    4662
    47 int tr_mkdir( const char * path, int permissions );
    4863
    4964uint8_t* tr_loadFile( const char * filename, size_t * size );
     
    6479int    tr_ioErrorFromErrno( void );
    6580
    66 char * tr_errorString( int code );
     81const char * tr_errorString( int code );
    6782
    6883/* return the current date in milliseconds */
Note: See TracChangeset for help on using the changeset viewer.