static const char * getOldCacheDir( void ) { static char * path = NULL; if( !path ) { #if defined( __BEOS__ ) || defined( WIN32 ) path = tr_buildPath( getOldConfigDir( ), "Cache", NULL ); #elif defined( SYS_DARWIN ) path = tr_buildPath( getHomeDir( ), "Library", "Caches", "Transmission", NULL ); #else path = tr_buildPath( getOldConfigDir( ), "cache", NULL ); #endif } return path; }
static const char * getOldTorrentsDir( void ) { static char * path = NULL; if( !path ) path = tr_buildPath( getOldConfigDir( ), TORRENT_SUBDIR, NULL ); return path; }
/** * 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 ); } }