Changeset 5242
- Timestamp:
- Mar 13, 2008, 1:06:54 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/tr-core.c
r5238 r5242 327 327 328 328 static void 329 maybeAddTorrent( TrCore * core, const char * filename ) 330 { 331 const gboolean isTorrent = g_str_has_suffix( filename, ".torrent" ); 332 333 if( isTorrent ) 334 { 335 struct TrCorePrivate * p = core->priv; 336 337 if( !g_list_find_custom( p->monitor_files, filename, (GCompareFunc)strcmp ) ) 338 p->monitor_files = g_list_append( p->monitor_files, g_strdup( filename ) ); 339 if( !p->monitor_idle_tag ) 340 p->monitor_idle_tag = g_timeout_add( 1000, watchFolderIdle, core ); 341 } 342 } 343 344 static void 329 345 watchFolderChanged( GFileMonitor * monitor UNUSED, 330 346 GFile * file, … … 336 352 { 337 353 char * filename = g_file_get_path( file ); 338 const gboolean isTorrent = g_str_has_suffix( filename, ".torrent" ); 339 340 if( isTorrent ) 341 { 342 struct TrCorePrivate * p = TR_CORE( core )->priv; 343 344 if( !g_list_find_custom( p->monitor_files, filename, (GCompareFunc)strcmp ) ) 345 p->monitor_files = g_list_append( p->monitor_files, g_strdup( filename ) ); 346 if( !p->monitor_idle_tag ) 347 p->monitor_idle_tag = g_timeout_add( 1000, watchFolderIdle, core ); 348 } 349 354 maybeAddTorrent( core, filename ); 350 355 g_free( filename ); 351 356 } … … 358 363 if( isEnabled ) 359 364 { 360 GList * torrents = NULL;361 365 char * dirname = pref_string_get( PREF_KEY_DIR_WATCH ); 362 366 GDir * dir = g_dir_open( dirname, 0, NULL ); 363 367 const char * basename; 364 while(( basename = g_dir_read_name( dir ))) 365 if( g_str_has_suffix( basename, ".torrent" ) )366 torrents = g_list_append( torrents, g_build_filename( dirname, basename, NULL ));367 if( torrents )368 tr_core_add_list( core, torrents, tr_ctorNew( core->priv->handle ) );368 while(( basename = g_dir_read_name( dir ))) { 369 char * filename = g_build_filename( dirname, basename, NULL ); 370 maybeAddTorrent( core, filename ); 371 g_free( filename ); 372 } 369 373 g_free( dirname ); 370 374 }
Note: See TracChangeset
for help on using the changeset viewer.