Changeset 10249


Ignore:
Timestamp:
Feb 21, 2010, 12:24:01 AM (12 years ago)
Author:
charles
Message:

(trunk daemon) #2943 "watch.c matches everything containing '.torrent'" -- use Longinus00's patch to fix this in trunk for 1.91

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/watch.c

    r10185 r10249  
    4141};
    4242
     43static tr_bool
     44str_has_suffix( const char *str, const char *suffix )
     45{
     46    const size_t str_len = strlen( str );
     47    const size_t suffix_len = strlen( suffix );
     48   
     49    if( str_len < suffix_len )
     50        return FALSE;
     51
     52    return !strncasecmp( str + str_len - suffix_len, suffix, suffix_len );
     53}
     54
    4355/***
    4456****  INOTIFY IMPLEMENTATION
     
    100112        while (i < len) {
    101113            struct inotify_event * event = (struct inotify_event *) &buf[i];
    102             if( strstr( event->name, ".torrent" ) != NULL )
     114            if( str_has_suffix( event->name, ".torrent" ) )
    103115            {
    104116                tr_inf( "Found new .torrent file \"%s\" in watchdir \"%s\"", event->name, w->dir );
     
    171183            if( !d->d_name || *d->d_name=='.' ) /* skip dotfiles */
    172184                continue;
    173             if( !strstr( d->d_name, ".torrent" ) ) /* skip non-torrents */
     185            if( !str_has_suffix( event->name, ".torrent" ) ) /* skip non-torrents */
    174186                continue;
    175187
Note: See TracChangeset for help on using the changeset viewer.