Ignore:
Timestamp:
Apr 26, 2009, 8:44:18 PM (13 years ago)
Author:
charles
Message:

(trunk libT) convert tr_open_file_for_scanning() and tr_close_file() to use file descriptors instead of file pointers so that we don't have to mix and match between them

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r8293 r8299  
    467467             size_t *     size )
    468468{
    469     uint8_t *    buf;
     469    uint8_t * buf;
    470470    struct stat  sb;
    471     FILE *       file;
     471    int fd;
    472472    const char * err_fmt = _( "Couldn't read \"%1$s\": %2$s" );
    473473
     
    490490
    491491    /* Load the torrent file into our buffer */
    492     file = tr_open_file_for_scanning( path );
    493     if( !file )
     492    fd = tr_open_file_for_scanning( path );
     493    if( fd < 0 )
    494494    {
    495495        const int err = errno;
     
    503503        const int err = errno;
    504504        tr_err( err_fmt, path, _( "Memory allocation failed" ) );
    505         tr_close_file( file );
     505        tr_close_file( fd );
    506506        errno = err;
    507507        return NULL;
    508508    }
    509     if( fread( buf, sb.st_size, 1, file ) != 1 )
     509    if( read( fd, buf, sb.st_size ) != sb.st_size )
    510510    {
    511511        const int err = errno;
    512512        tr_err( err_fmt, path, tr_strerror( errno ) );
    513         tr_close_file( file );
     513        tr_close_file( fd );
    514514        free( buf );
    515515        errno = err;
     
    517517    }
    518518
    519     tr_close_file( file );
     519    tr_close_file( fd );
    520520    *size = sb.st_size;
    521521    return buf;
Note: See TracChangeset for help on using the changeset viewer.