Ignore:
Timestamp:
Dec 9, 2009, 3:40:35 AM (12 years ago)
Author:
charles
Message:

(trunk libT) by request, add a clientData argument to tr_torrentDeleteLocalData()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r9689 r9690  
    23172317
    23182318static void
    2319 deleteLocalFile( const char * filename, tr_fileFunc fileFunc )
     2319deleteLocalFile( const char * filename, tr_fileFunc fileFunc, void * fileFuncClientData )
    23202320{
    23212321    struct stat sb;
    23222322    if( !stat( filename, &sb ) ) /* if file exists... */
    2323         fileFunc( filename );
     2323        fileFunc( filename, fileFuncClientData );
    23242324}
    23252325
    23262326static void
    2327 deleteLocalData( tr_torrent * tor, tr_fileFunc fileFunc )
     2327deleteLocalData( tr_torrent * tor, tr_fileFunc fileFunc, void * fileFuncClientData )
    23282328{
    23292329    int i, n;
     
    23532353    for( i=0; i<n; ++i )
    23542354        if( tr_ptrArrayFindSorted( &dirtyFolders, s[i], vstrcmp ) == NULL )
    2355             deleteLocalFile( s[i], fileFunc );
     2355            deleteLocalFile( s[i], fileFunc, fileFuncClientData );
    23562356
    23572357    /* now blow away any remaining torrent files, such as torrent files in dirty folders */
    23582358    for( f=0; f<tor->info.fileCount; ++f ) {
    23592359        char * path = tr_buildPath( tor->currentDir, tor->info.files[f].name, NULL );
    2360         deleteLocalFile( path, fileFunc );
     2360        deleteLocalFile( path, fileFunc, fileFuncClientData );
    23612361        tr_free( path );
    23622362    }
     
    23752375#ifdef SYS_DARWIN
    23762376            char * dsStore = tr_buildPath( s[i], ".DS_Store", NULL );
    2377             deleteLocalFile( dsStore, fileFunc );
     2377            deleteLocalFile( dsStore, fileFunc, fileFuncClientData );
    23782378            tr_free( dsStore );
    23792379#endif
    2380             deleteLocalFile( s[i], fileFunc );
     2380            deleteLocalFile( s[i], fileFunc, fileFuncClientData );
    23812381        }
    23822382        tr_ptrArrayDestruct( &cleanFolders, NULL );
     
    23912391}
    23922392
    2393 void
    2394 tr_torrentDeleteLocalData( tr_torrent * tor, tr_fileFunc fileFunc )
     2393static int
     2394removeFile( const char * filename, void * unused UNUSED )
     2395{
     2396    return remove( filename );
     2397}
     2398
     2399void
     2400tr_torrentDeleteLocalData( tr_torrent * tor, tr_fileFunc fileFunc, void * fileFuncClientData )
    23952401{
    23962402    assert( tr_isTorrent( tor ) );
    23972403
    23982404    if( fileFunc == NULL )
    2399         fileFunc = remove;
     2405        fileFunc = removeFile;
    24002406
    24012407    /* close all the files because we're about to delete them */
     
    24042410    if( tor->info.fileCount > 1 )
    24052411    {
    2406         deleteLocalData( tor, fileFunc );
     2412        deleteLocalData( tor, fileFunc, fileFuncClientData );
    24072413    }
    24082414    else if( tor->info.fileCount == 1 )
     
    24122418        /* torrent only has one file */
    24132419        char * path = tr_buildPath( tor->currentDir, tor->info.files[0].name, NULL );
    2414         deleteLocalFile( path, fileFunc );
     2420        deleteLocalFile( path, fileFunc, fileFuncClientData );
    24152421        tr_free( path );
    24162422
    24172423        tmp = tr_torrentBuildPartial( tor, 0 );
    24182424        path = tr_buildPath( tor->currentDir, tmp, NULL );
    2419         deleteLocalFile( path, fileFunc );
     2425        deleteLocalFile( path, fileFunc, fileFuncClientData );
    24202426        tr_free( path );
    24212427        tr_free( tmp );
     
    25102516            /* blow away the leftover subdirectories in the old location */
    25112517            if( do_move )
    2512                 tr_torrentDeleteLocalData( tor, remove );
     2518                tr_torrentDeleteLocalData( tor, removeFile, NULL );
    25132519
    25142520            /* set the new location and reverify */
Note: See TracChangeset for help on using the changeset viewer.