예제 #1
0
static char* getResumeFilename(tr_torrent const* tor)
{
    char* base = tr_metainfoGetBasename(tr_torrentInfo(tor));
    char* filename = tr_strdup_printf("%s" TR_PATH_DELIMITER_STR "%s.resume", tr_getResumeDir(tor->session), base);
    tr_free(base);
    return filename;
}
예제 #2
0
파일: resume.c 프로젝트: fangang190/canary
static char*
getResumeFilename( const tr_torrent * tor )
{
    return tr_strdup_printf( "%s%c%s.%16.16s.resume",
                             tr_getResumeDir( tor->session ),
                             TR_PATH_DELIMITER,
                             tor->info.name,
                             tor->info.hashString );
}
예제 #3
0
void
tr_fastResumeRemove( const tr_torrent * tor )
{
    const char * cacheDir = tr_getResumeDir( tor->session );
    const char * hash = tor->info.hashString;

    if( tor->session->tag )
    {
        char * path = tr_strdup_printf( "%s" TR_PATH_DELIMITER_STR "%s-%s", cacheDir, hash, tor->session->tag );
        unlink( path );
        tr_free( path );
    }
    else
    {
        char * path = tr_buildPath( cacheDir, hash, NULL );
        unlink( path );
        tr_free( path );
    }
}
예제 #4
0
static void
migrateFiles( const tr_handle * handle )
{
    static int migrated = FALSE;

    if( !migrated )
    {
        const char * oldDir;
        const char * newDir;
        migrated = TRUE;

        oldDir = getOldTorrentsDir( );
        newDir = tr_getTorrentDir( handle );
        moveFiles( oldDir, newDir );

        oldDir = getOldCacheDir( );
        newDir = tr_getResumeDir( handle );
        moveFiles( oldDir, newDir );
    }
}
예제 #5
0
/**
 * This function is for transmission-gtk users to migrate the config files
 * from $HOME/.transmission/ (where they were kept before Transmission 1.30)
 * to $HOME/.config/$appname as per the XDG directory spec.
 */
static void
migrateFiles( const tr_session * session )
{
    static int migrated = FALSE;
    const tr_bool should_migrate = strstr( getOldConfigDir(), ".transmission" ) != NULL;

    if( !migrated && should_migrate )
    {
        const char * oldDir;
        const char * newDir;
        migrated = TRUE;

        oldDir = getOldTorrentsDir( );
        newDir = tr_getTorrentDir( session );
        moveFiles( oldDir, newDir );

        oldDir = getOldCacheDir( );
        newDir = tr_getResumeDir( session );
        moveFiles( oldDir, newDir );
    }
}
예제 #6
0
static uint8_t*
loadResumeFile( const tr_torrent * tor,
                size_t *           len )
{
    uint8_t *    ret = NULL;
    const char * cacheDir = tr_getResumeDir( tor->session );
    const char * hash = tor->info.hashString;

    if( !ret && tor->session->tag )
    {
        char * path = tr_strdup_printf( "%s" TR_PATH_DELIMITER_STR "%s-%s", cacheDir, hash, tor->session->tag );
        ret = tr_loadFile( path, len );
        tr_free( path );
    }
    if( !ret )
    {
        char * path = tr_buildPath( cacheDir, hash, NULL );
        ret = tr_loadFile( path, len );
        tr_free( path );
    }

    return ret;
}