Advertisement
Guest User

Longinus00

a guest
Feb 19th, 2010
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. Index: watch.c
  2. ===================================================================
  3. --- watch.c (revision 10235)
  4. +++ watch.c (working copy)
  5. @@ -120,12 +120,6 @@
  6. #define FILE_DELIMITER '\0'
  7.  
  8. static void
  9. -watchdir_new_impl( dtr_watchdir * w UNUSED )
  10. -{
  11. - tr_inf( "Using readdir to watch directory \"%s\"", w->dir );
  12. - w->lastFiles = evbuffer_new( );
  13. -}
  14. -static void
  15. watchdir_free_impl( dtr_watchdir * w )
  16. {
  17. evbuffer_free( w->lastFiles );
  18. @@ -149,6 +143,37 @@
  19. return in_list;
  20. }
  21. static void
  22. +watchdir_new_impl( dtr_watchdir * w UNUSED )
  23. +{
  24. + struct stat sb;
  25. + DIR * odir;
  26. + const char * dirname = w->dir;
  27. + struct evbuffer * curFiles = evbuffer_new( );
  28. + tr_inf( "Using readdir to watch directory \"%s\"", w->dir );
  29. +
  30. + if( !stat( dirname, &sb )
  31. + && S_ISDIR( sb.st_mode )
  32. + && (( odir = opendir( dirname ) ) ) )
  33. + {
  34. + struct dirent * d;
  35. +
  36. + for( d = readdir( odir ); d != NULL; d = readdir( odir ) )
  37. + {
  38. + size_t len;
  39. +
  40. + if( !d->d_name || *d->d_name=='.' ) /* skip dotfiles */
  41. + continue;
  42. + if( !strstr( d->d_name, ".torrent" ) ) /* skip non-torrents */
  43. + continue;
  44. +
  45. + len = strlen( d->d_name );
  46. + add_file_to_list( curFiles, d->d_name, len );
  47. + }
  48. + }
  49. + closedir( odir );
  50. + w->lastFiles = curFiles;
  51. +}
  52. +static void
  53. watchdir_update_impl( dtr_watchdir * w )
  54. {
  55. struct stat sb;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement