Changeset 2455
- Timestamp:
- Jul 21, 2007, 6:46:54 PM (15 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/transmission.c
r2444 r2455 24 24 25 25 #include <signal.h> 26 #include <sys/types.h> /* stat */ 27 #include <sys/stat.h> /* stat */ 28 #include <unistd.h> /* stat */ 29 #include <dirent.h> /* opendir */ 26 30 #include "transmission.h" 27 31 #include "fdlimit.h" 32 #include "list.h" 28 33 #include "net.h" 29 34 #include "shared.h" … … 225 230 tr_netResolveThreadClose(); 226 231 } 232 233 tr_torrent_t ** 234 tr_loadTorrents ( tr_handle_t * h, 235 const char * destination, 236 int flags, 237 int * setmeCount ) 238 { 239 int i, n = 0; 240 struct stat sb; 241 DIR * odir = NULL; 242 const char * torrentDir = tr_getTorrentsDirectory( ); 243 tr_torrent_t ** torrents; 244 tr_list_t *l=NULL, *list=NULL; 245 246 if( !stat( torrentDir, &sb ) 247 && S_ISDIR( sb.st_mode ) 248 && (( odir = opendir ( torrentDir ) )) ) 249 { 250 struct dirent *d; 251 for (d = readdir( odir ); d!=NULL; d=readdir( odir ) ) 252 { 253 if( d->d_name && d->d_name[0]!='.' ) /* skip dotfiles, ., and .. */ 254 { 255 tr_torrent_t * tor; 256 char path[MAX_PATH_LENGTH]; 257 tr_buildPath( path, sizeof(path), torrentDir, d->d_name, NULL ); 258 tor = tr_torrentInit( h, path, destination, flags, NULL ); 259 if( tor != NULL ) { 260 list = tr_list_append( list, tor ); 261 //fprintf (stderr, "#%d - %s\n", n, tor->info.name ); 262 n++; 263 } 264 } 265 } 266 closedir( odir ); 267 } 268 269 torrents = tr_new( tr_torrent_t*, n ); 270 for( i=0, l=list; l!=NULL; l=l->next ) 271 torrents[i++] = (tr_torrent_t*) l->data; 272 assert( i==n ); 273 274 tr_list_free( list ); 275 276 *setmeCount = n; 277 tr_inf( "Loaded %d torrents from disk", *setmeCount ); 278 return torrents; 279 } -
trunk/libtransmission/transmission.h
r2444 r2455 285 285 void tr_close( tr_handle_t * ); 286 286 287 288 289 /** 290 * Load all the torrents in tr_getTorrentsDirectory(). 291 * This can be used at startup to kickstart all the torrents 292 * from the previous session. 293 */ 294 tr_torrent_t ** tr_loadTorrents ( tr_handle_t * h, 295 const char * destination, 296 int flags, 297 int * setmeCount ); 298 299 287 300 /*********************************************************************** 288 301 * tr_torrentInit
Note: See TracChangeset
for help on using the changeset viewer.