Changeset 9690


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()

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-torrent.c

    r9503 r9690  
    282282}
    283283
     284static int
     285deleteFile( const char * filename, void * unused UNUSED )
     286{
     287    return tr_file_trash_or_remove( filename );
     288}
     289
    284290void
    285291tr_torrent_delete_files( TrTorrent * gtor )
    286292{
    287     tr_torrentDeleteLocalData( tr_torrent_handle( gtor ), tr_file_trash_or_remove );
     293    tr_torrentDeleteLocalData( tr_torrent_handle( gtor ), deleteFile, NULL );
    288294}
    289295
  • trunk/libtransmission/rpcimpl.c

    r9687 r9690  
    240240        tr_bool deleteFlag;
    241241        if( tr_bencDictFindBool( args_in, "delete-local-data", &deleteFlag ) && deleteFlag )
    242             tr_torrentDeleteLocalData( tor, NULL );
     242            tr_torrentDeleteLocalData( tor, NULL, NULL );
    243243        if( !( status & TR_RPC_NOREMOVE ) )
    244244            tr_torrentRemove( tor );
  • 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 */
  • trunk/libtransmission/transmission.h

    r9644 r9690  
    10081008void tr_torrentStop( tr_torrent * torrent );
    10091009
    1010 typedef int tr_fileFunc( const char * filename );
    1011 
    10121010enum
    10131011{
     
    10241022                            int         * setme_state );
    10251023
     1024typedef int tr_fileFunc( const char * filename, void * clientData );
     1025
    10261026/**
    10271027 * @brief Deletes the torrent's local data.
     
    10311031 *                 tr_torrentDeleteLocalData() ignores fileFunc's return value.
    10321032 */
    1033 void tr_torrentDeleteLocalData( tr_torrent * torrent,  tr_fileFunc fileFunc );
     1033void tr_torrentDeleteLocalData( tr_torrent   * torrent,
     1034                                tr_fileFunc    fileFunc,
     1035                                void         * fileFuncClientData );
    10341036
    10351037uint64_t tr_torrentGetBytesLeftToAllocate( const tr_torrent * torrent );
Note: See TracChangeset for help on using the changeset viewer.