#684: Use XDG basedir spec for configuration and cache files in $HOME · transmission/transmission@b71a298
@@ -125,25 +125,30 @@ strlcat_utf8( void * dest, const void * src, size_t len, char skip )
125125}
126126127127static void
128-savedname( char * name, size_t len, const char * hash, const char * tag )
128+savedname( const tr_handle * handle,
129+char * name,
130+size_t len,
131+const char * hash )
129132{
130-const char * torDir = tr_getTorrentsDirectory ();
133+const char * torDir = tr_getTorrentDir( handle );
131134132-if( tag == NULL )
135+if( !handle->tag )
133136 {
134137tr_buildPath( name, len, torDir, hash, NULL );
135138 }
136139else
137140 {
138141char base[1024];
139-snprintf( base, sizeof(base), "%s-%s", hash, tag );
142+snprintf( base, sizeof(base), "%s-%s", hash, handle->tag );
140143tr_buildPath( name, len, torDir, base, NULL );
141144 }
142145}
143146144147145148int
146-tr_metainfoParse( tr_info * inf, const tr_benc * meta_in, const char * tag )
149+tr_metainfoParse( const tr_handle * handle,
150+tr_info * inf,
151+const tr_benc * meta_in )
147152{
148153tr_piece_index_t i;
149154tr_benc * beInfo, * val, * val2;
@@ -167,7 +172,7 @@ tr_metainfoParse( tr_info * inf, const tr_benc * meta_in, const char * tag )
167172 }
168173169174tr_sha1_to_hex( inf->hashString, inf->hash );
170-savedname( buf, sizeof( buf ), inf->hashString, tag );
175+savedname( handle, buf, sizeof( buf ), inf->hashString );
171176tr_free( inf->torrent );
172177inf->torrent = tr_strdup( buf );
173178@@ -563,22 +568,25 @@ tr_trackerInfoClear( tr_tracker_info * info )
563568}
564569565570void
566-tr_metainfoRemoveSaved( const char * hashString, const char * tag )
571+tr_metainfoRemoveSaved( const tr_handle * handle,
572+const char * hashString )
567573{
568574char file[MAX_PATH_LENGTH];
569-savedname( file, sizeof file, hashString, tag );
575+savedname( handle, file, sizeof file, hashString );
570576unlink( file );
571577}
572578573579/* Save a copy of the torrent file in the saved torrent directory */
574580int
575-tr_metainfoSave( const char * hash, const char * tag,
576-const uint8_t * buf, size_t buflen )
581+tr_metainfoSave( const tr_handle * handle,
582+const char * hash,
583+const uint8_t * buf,
584+size_t buflen )
577585{
578586char path[MAX_PATH_LENGTH];
579587FILE * file;
580588581-savedname( path, sizeof path, hash, tag );
589+savedname( handle, path, sizeof path, hash );
582590file = fopen( path, "wb+" );
583591if( !file )
584592 {