Ignore:
Timestamp:
Aug 14, 2009, 12:53:08 PM (11 years ago)
Author:
charles
Message:

(trunk) move tr_lockfile from libtransmission/ to gtk/, since the gtk client is the only one who uses it anymore

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/platform.c

    r8889 r8929  
    664664***/
    665665
    666 tr_lockfile_state_t
    667 tr_lockfile( const char * filename )
    668 {
    669     tr_lockfile_state_t ret;
    670 
    671 #ifdef WIN32
    672 
    673     HANDLE              file = CreateFile(
    674         filename,
    675         GENERIC_READ | GENERIC_WRITE,
    676         FILE_SHARE_READ |
    677         FILE_SHARE_WRITE,
    678         NULL,
    679         OPEN_ALWAYS,
    680         FILE_ATTRIBUTE_NORMAL,
    681         NULL );
    682     if( file == INVALID_HANDLE_VALUE )
    683         ret = TR_LOCKFILE_EOPEN;
    684     else if( !LockFile( file, 0, 0, 1, 1 ) )
    685         ret = TR_LOCKFILE_ELOCK;
    686     else
    687         ret = TR_LOCKFILE_SUCCESS;
    688 
    689 #else
    690 
    691     int fd = open( filename, O_RDWR | O_CREAT, 0666 );
    692     if( fd < 0 )
    693         ret = TR_LOCKFILE_EOPEN;
    694     else
    695     {
    696         struct flock lk;
    697         memset( &lk, 0,  sizeof( lk ) );
    698         lk.l_start = 0;
    699         lk.l_len = 0;
    700         lk.l_type = F_WRLCK;
    701         lk.l_whence = SEEK_SET;
    702         if( -1 == fcntl( fd, F_SETLK, &lk ) )
    703             ret = TR_LOCKFILE_ELOCK;
    704         else
    705             ret = TR_LOCKFILE_SUCCESS;
    706     }
    707 
    708 #endif
    709 
    710     return ret;
    711 }
    712 
    713666#ifdef WIN32
    714667
Note: See TracChangeset for help on using the changeset viewer.