static void fs_event_unlink_files(uv_timer_t* handle) { int r; int i; /* NOTE: handle might be NULL if invoked not as timer callback */ if (handle == NULL) { /* Unlink all files */ for (i = 0; i < 16; i++) { r = remove(fs_event_get_filename(i)); if (handle != NULL) ASSERT(r == 0); } } else { /* Make sure we're not attempting to remove files we do not intend */ ASSERT(fs_event_removed < fs_event_file_count); /* Remove the file */ ASSERT(0 == remove(fs_event_get_filename(fs_event_removed))); if (++fs_event_removed < fs_event_file_count) { /* Remove another file on a different event loop tick. We do it this way * to avoid fs events coalescing into one fs event. */ ASSERT(0 == uv_timer_start(&timer, fs_event_unlink_files, 1, 0)); } } }
static void fs_event_create_files(uv_timer_t* handle) { int i; /* Already created all files */ if (fs_event_created == fs_event_file_count) { uv_close((uv_handle_t*) &timer, close_cb); return; } /* Create all files */ for (i = 0; i < 16; i++, fs_event_created++) create_file(handle->loop, fs_event_get_filename(i)); /* And unlink them */ ASSERT(0 == uv_timer_start(&timer, fs_event_unlink_files, 50, 0)); }
static void fs_event_create_files(uv_timer_t* handle) { /* Make sure we're not attempting to create files we do not intend */ ASSERT(fs_event_created < fs_event_file_count); /* Create the file */ create_file(fs_event_get_filename(fs_event_created)); if (++fs_event_created < fs_event_file_count) { /* Create another file on a different event loop tick. We do it this way * to avoid fs events coalescing into one fs event. */ ASSERT(0 == uv_timer_start(&timer, fs_event_create_files, CREATE_TIMEOUT, 0)); } }
void fs_event_unlink_files(uv_timer_t* handle) { int r; int i; /* NOTE: handle might be NULL if invoked not as timer callback */ /* Unlink all files */ for (i = 0; i < 16; i++) { r = remove(fs_event_get_filename(i)); if (handle != NULL) ASSERT(r == 0); } /* And create them again */ if (handle != NULL) ASSERT(0 == uv_timer_start(&timer, fs_event_create_files, 50, 0)); }