Changeset 2578


Ignore:
Timestamp:
Aug 1, 2007, 12:40:49 AM (15 years ago)
Author:
charles
Message:

More Win32 portability changes

Location:
trunk/libtransmission
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r2573 r2578  
    8181 * Local prototypes
    8282 **********************************************************************/
    83 static int  OpenFile( int i, const char * folder, const char * name, int write );
    84 static void CloseFile( int i );
     83static int  TrOpenFile( int i, const char * folder, const char * name, int write );
     84static void TrCloseFile( int i );
    8585
    8686
     
    167167            /* File is open read-only and needs to be closed then
    168168             * re-opened read-write */
    169             CloseFile( i );
     169            TrCloseFile( i );
    170170            continue;
    171171        }
     
    205205        if( winner >= 0 )
    206206        {
    207             CloseFile( winner );
     207            TrCloseFile( winner );
    208208            goto open;
    209209        }
     
    214214
    215215open:
    216     if( ( ret = OpenFile( winner, folder, name, write ) ) )
     216    if( ( ret = TrOpenFile( winner, folder, name, write ) ) )
    217217    {
    218218        tr_lockUnlock( gFd->lock );
     
    270270            !strcmp( name, gFd->open[i].name ) )
    271271        {
    272             CloseFile( i );
     272            TrCloseFile( i );
    273273        }
    274274    }
     
    424424 *
    425425 **********************************************************************/
    426 static int OpenFile( int i, const char * folder, const char * name, int write )
     426static int TrOpenFile( int i, const char * folder, const char * name, int write )
    427427{
    428428    tr_openFile_t * file = &gFd->open[i];
     
    454454            if( stat( path, &sb ) )
    455455            {
    456                 if( mkdir( path, 0777 ) )
     456                if( tr_mkdir( path, 0777 ) )
    457457                {
    458458                    ret = tr_ioErrorFromErrno();
     
    491491
    492492/***********************************************************************
    493  * CloseFile
     493 * TrCloseFile
    494494 ***********************************************************************
    495495 * We first mark it as closing then release the lock while doing so,
     
    497497 * threads.
    498498 **********************************************************************/
    499 static void CloseFile( int i )
     499static void TrCloseFile( int i )
    500500{
    501501    tr_openFile_t * file = &gFd->open[i];
     
    515515    if( file->status & STATUS_USED )
    516516    {
    517         tr_err( "CloseFile: closing a file that's being used!" );
     517        tr_err( "TrCloseFile: closing a file that's being used!" );
    518518    }
    519519    tr_dbg( "Closing %s in %s (%d)", file->name, file->folder, file->write );
  • trunk/libtransmission/net.c

    r2576 r2578  
    241241static int makeSocketNonBlocking( int s )
    242242{
    243     int flags;
    244 
    245 #ifdef SYS_BEOS
    246     flags = 1;
     243#ifdef SYS_WIN32
     244    unsigned long flags = 1;
     245    if( ioctlsocket( sock, FIONBIO, &flags) == SOCKET_ERROR )
     246#elif defined(SYS_BEOS)
     247    int flags = 1;
    247248    if( setsockopt( s, SOL_SOCKET, SO_NONBLOCK,
    248249                    &flags, sizeof( int ) ) < 0 )
    249250#else
     251    int flags = 1;
    250252    if( ( flags = fcntl( s, F_GETFL, 0 ) ) < 0 ||
    251253        fcntl( s, F_SETFL, flags | O_NONBLOCK ) < 0 )
  • trunk/libtransmission/net.h

    r2576 r2578  
    4343
    4444#ifdef WIN32
    45     #define EAGAIN       WSAEAGAIN
    4645    #define ECONNREFUSED WSAECONNREFUSED
    4746    #define ECONNRESET   WSAECONNRESET
  • trunk/libtransmission/platform.c

    r2577 r2578  
    3333  #include <kernel/OS.h>
    3434  #define BEOS_MAX_THREADS 256
     35#elif defined(WIN32)
    3536#else
    3637  #include <pthread.h>
     
    128129        wait_for_thread( t->thread, &exit );
    129130#elif defined(WIN32)
    130         WaitForSingleObject(thread->handle, INFINITE);
     131        WaitForSingleObject( t->thread, INFINITE );
    131132        CloseHandle( t->thread );
    132133#else
     
    549550#endif
    550551
    551     tr_mkdir( buf );
     552    tr_mkdirp( buf, 0700 );
    552553    init = 1;
    553554
     
    583584#endif
    584585
    585     tr_mkdir( buf );
     586    tr_mkdirp( buf, 0700 );
    586587    init = 1;
    587588
     
    613614#endif
    614615
    615     tr_mkdir( buf );
     616    tr_mkdirp( buf, 0700 );
    616617    init = 1;
    617618    return buf;
  • trunk/libtransmission/utils.c

    r2552 r2578  
    231231
    232232
    233 int tr_mkdir( char * path )
     233int
     234tr_mkdir( const char * path, int permissions
     235#ifdef WIN32
     236                                             UNUSED
     237#endif
     238                                                    )
     239{
     240#ifdef WIN32
     241    return mkdir( path );
     242#else
     243    return mkdir( path, permissions );
     244#endif
     245}
     246
     247int
     248tr_mkdirp( char * path, int permissions )
    234249{
    235250    char      * p, * pp;
     
    255270        {
    256271            /* Folder doesn't exist yet */
    257             if( mkdir( path, 0777 ) )
     272            if( tr_mkdir( path, permissions ) )
    258273            {
    259274                tr_err( "Could not create directory %s (%s)", path,
  • trunk/libtransmission/utils.h

    r2538 r2578  
    4141
    4242/***********************************************************************
    43  * tr_mkdir
     43 * tr_mkdirp
    4444 ***********************************************************************
    4545 * Create a directory and any needed parent directories.
    4646 * Note that the string passed in must be writable!
    4747 **********************************************************************/
    48 int tr_mkdir( char * path );
     48int tr_mkdirp( char * path, int permissions );
     49
     50int tr_mkdir( const char * path, int permissions );
    4951
    5052/***********************************************************************
Note: See TracChangeset for help on using the changeset viewer.