struct tr_openfile
{
- tr_bool isCheckedOut;
tr_bool isWritable;
int torrentId;
char filename[MAX_PATH_LENGTH];
tr_close_file( o->fd );
o->fd = -1;
- o->isCheckedOut = FALSE;
-}
-
-static int
-fileIsCheckedOut( const struct tr_openfile * o )
-{
- return fileIsOpen( o ) && o->isCheckedOut;
}
/* returns an fd on success, or a -1 on failure and sets errno */
if( strcmp( filename, o->filename ) )
continue;
- assert( !fileIsCheckedOut( o ) );
-
if( doWrite && !o->isWritable )
{
dbgmsg( "found it! it's open and available, but isn't writable. closing..." );
dbgmsg( "checking out '%s' in slot %d", filename, winner );
o->torrentId = torrentId;
- o->isCheckedOut = 1;
o->date = tr_date( );
return o->fd;
}
if( o->fd != fd )
continue;
dbgmsg( "releasing file \"%s\"", o->filename );
- o->isCheckedOut = FALSE;
break;
}
}
if( !fileIsOpen( o ) || strcmp( filename, o->filename ) )
continue;
dbgmsg( "tr_fdFileClose closing \"%s\"", filename );
- assert( !o->isCheckedOut && "this is a test assertion... I *think* this is always true now" );
TrCloseFile( o );
}
}