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; }
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 ); }
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 ); } }
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 ); } }
/** * 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 ); } }
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; }