Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: watch.c
- ===================================================================
- --- watch.c (revision 10235)
- +++ watch.c (working copy)
- @@ -120,12 +120,6 @@
- #define FILE_DELIMITER '\0'
- static void
- -watchdir_new_impl( dtr_watchdir * w UNUSED )
- -{
- - tr_inf( "Using readdir to watch directory \"%s\"", w->dir );
- - w->lastFiles = evbuffer_new( );
- -}
- -static void
- watchdir_free_impl( dtr_watchdir * w )
- {
- evbuffer_free( w->lastFiles );
- @@ -149,6 +143,37 @@
- return in_list;
- }
- static void
- +watchdir_new_impl( dtr_watchdir * w UNUSED )
- +{
- + struct stat sb;
- + DIR * odir;
- + const char * dirname = w->dir;
- + struct evbuffer * curFiles = evbuffer_new( );
- + tr_inf( "Using readdir to watch directory \"%s\"", w->dir );
- +
- + if( !stat( dirname, &sb )
- + && S_ISDIR( sb.st_mode )
- + && (( odir = opendir( dirname ) ) ) )
- + {
- + struct dirent * d;
- +
- + for( d = readdir( odir ); d != NULL; d = readdir( odir ) )
- + {
- + size_t len;
- +
- + if( !d->d_name || *d->d_name=='.' ) /* skip dotfiles */
- + continue;
- + if( !strstr( d->d_name, ".torrent" ) ) /* skip non-torrents */
- + continue;
- +
- + len = strlen( d->d_name );
- + add_file_to_list( curFiles, d->d_name, len );
- + }
- + }
- + closedir( odir );
- + w->lastFiles = curFiles;
- +}
- +static void
- watchdir_update_impl( dtr_watchdir * w )
- {
- struct stat sb;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement