Changeset 11643


Ignore:
Timestamp:
Jan 7, 2011, 12:17:13 AM (11 years ago)
Author:
jordan
Message:

(trunk libT) minor code cleanup in fdlimit.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r11633 r11643  
    7171 #define O_LARGEFILE 0
    7272#endif
     73
     74#ifndef O_BINARY
     75 #define O_BINARY 0
     76#endif
     77
     78#ifndef O_SEQUENTIAL
     79 #define O_SEQUENTIAL 0
     80#endif
     81
    7382
    7483static tr_bool
     
    254263}
    255264
    256 int
    257 tr_open_file_for_writing( const char * filename )
    258 {
    259     int fd;
    260     int flags = O_WRONLY | O_CREAT;
    261 #ifdef O_BINARY
    262     flags |= O_BINARY;
    263 #endif
    264 #ifdef O_LARGEFILE
    265     flags |= O_LARGEFILE;
    266 #endif
    267     fd = open( filename, flags, 0666 );
     265static int
     266open_local_file( const char * filename, int flags )
     267{
     268    const int fd = open( filename, flags, 0666 );
    268269    tr_set_file_for_single_pass( fd );
    269270    return fd;
    270271}
    271 
     272int
     273tr_open_file_for_writing( const char * filename )
     274{
     275    return open_local_file( filename, O_LARGEFILE|O_BINARY|O_CREAT|O_WRONLY );
     276}
    272277int
    273278tr_open_file_for_scanning( const char * filename )
    274279{
    275     int fd;
    276     int flags;
    277 
    278     /* build the flags */
    279     flags = O_RDONLY;
    280 #ifdef O_SEQUENTIAL
    281     flags |= O_SEQUENTIAL;
    282 #endif
    283 #ifdef O_BINARY
    284     flags |= O_BINARY;
    285 #endif
    286 #ifdef O_LARGEFILE
    287     flags |= O_LARGEFILE;
    288 #endif
    289 
    290     /* open the file */
    291     fd = open( filename, flags, 0666 );
    292     tr_set_file_for_single_pass( fd );
    293     return fd;
     280    return open_local_file( filename, O_LARGEFILE|O_BINARY|O_SEQUENTIAL|O_RDONLY );
    294281}
    295282
     
    381368    /* open the file */
    382369    flags = writable ? ( O_RDWR | O_CREAT ) : O_RDONLY;
    383 #ifdef O_SEQUENTIAL
    384     flags |= O_SEQUENTIAL;
    385 #endif
    386 #ifdef O_LARGEFILE
    387     flags |= O_LARGEFILE;
    388 #endif
    389 #ifdef WIN32
    390     flags |= O_BINARY;
    391 #endif
     370    flags |= O_LARGEFILE | O_BINARY | O_SEQUENTIAL;
    392371    o->fd = open( filename, flags, 0666 );
    393372
Note: See TracChangeset for help on using the changeset viewer.