Hi all,

Using the code below, I am expecting the event loop to run the callback when I touch or edit the file to which I am pointing (directorry->directory), but for some reason this doesn't happen.

The timeout does work however.

Can anyone tell me if I am doing something stupid, or whether there are known problems with MacOSX 10.5?

static void watch_directory_cb(struct ev_loop *loop, ev_stat *w, int revents) {
// we never reach here
        if (w->attr.st_nlink) {
printf("passwd current size %ld\n", (long) w->attr.st_size); printf("passwd current atime %ld\n", (long) w->attr.st_mtime); printf("passwd current mtime %ld\n", (long) w->attr.st_mtime);
        } else
                /* you shalt not abuse printf for puts */
                puts("directory does not exist.\n");
}

// another callback, this time for a time-out
static void
watch_timeout_cb (EV_P_ struct ev_timer *w, int revents)
{
        puts ("timeout");
        // this causes the innermost ev_loop to stop iterating
        ev_unloop (EV_A_ EVUNLOOP_ONE);
}


The code:

        ev_stat directory_watcher;
        ev_timer timeout_watcher;

                directory->loop = ev_loop_new(0);

                /* initialise an io watcher, then start it */
                ev_stat_init(&directory_watcher, watch_directory_cb,
                                directory->directory, 0.);
                ev_stat_start(directory->loop, &directory_watcher);

                /* initialise a timer watcher, then start it */
ev_timer_init(&timeout_watcher, watch_timeout_cb, TIMEOUT, 0.);
                ev_timer_start(directory->loop, &timeout_watcher);

                /* now wait for events to arrive */
                ev_loop(directory->loop, 0);

Regards,
Graham
--

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to