void uv__fs_event_close(uv_fs_event_t* handle) { #ifdef HAVE_SYS_AHAFS_EVPRODS_H uv_fs_event_stop(handle); #else UNREACHABLE(); #endif }
static int luv_fs_event_stop(lua_State* L) { uv_fs_event_t* handle = luv_check_fs_event(L, 1); int ret = uv_fs_event_stop(handle); if (ret < 0) return luv_error(L, ret); lua_pushinteger(L, ret); return 1; }
void uv_fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle) { uv_fs_event_stop(handle); uv__handle_closing(handle); if (!handle->req_pending) { uv_want_endgame(loop, (uv_handle_t*)handle); } }
static void fs_event_cb_file(uv_fs_event_t* handle, const char* filename, int events, int status) { ++fs_event_cb_called; ASSERT(handle == &fs_event); ASSERT(status == 0); ASSERT(events == UV_CHANGE); ASSERT(filename == NULL || strcmp(filename, "file2") == 0); ASSERT(0 == uv_fs_event_stop(handle)); uv_close((uv_handle_t*)handle, close_cb); }
static void lws_protocol_dir_kill_monitor(struct per_session_data__tbl_dir *pss) { if (!pss->event_req) return; pss->wsi = NULL; pss->event_req->data = NULL; uv_fs_event_stop(pss->event_req); uv_close((uv_handle_t *)pss->event_req, lws_uv_close_cb); pss->event_req = NULL; }
static void timer_cb_exact(uv_timer_t* handle) { int r; if (timer_cb_exact_called == 0) { touch_file("watch_dir/file.js"); } else { uv_close((uv_handle_t*)handle, NULL); r = uv_fs_event_stop(&fs_event); ASSERT(r == 0); uv_close((uv_handle_t*) &fs_event, NULL); } ++timer_cb_exact_called; }
static void fs_event_cb_file(uv_fs_event_t* handle, const char* filename, int events, int status) { ++fs_event_cb_called; ASSERT(handle == &fs_event); ASSERT(status == 0); ASSERT(events == UV_CHANGE); #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__) ASSERT(strcmp(filename, "file2") == 0); #else ASSERT(filename == NULL || strcmp(filename, "file2") == 0); #endif ASSERT(0 == uv_fs_event_stop(handle)); uv_close((uv_handle_t*)handle, close_cb); }
static void fs_event_cb_dir_multi_file_in_subdir(uv_fs_event_t* handle, const char* filename, int events, int status) { fs_event_cb_called++; ASSERT(handle == &fs_event); ASSERT(status == 0); ASSERT(events == UV_RENAME || events == UV_CHANGE); ASSERT(filename == NULL || strncmp(filename, file_prefix_in_subdir, sizeof(file_prefix_in_subdir) - 1) == 0); /* Stop watching dir when received events about all files: * both create and close events */ if (fs_event_cb_called == 2 * fs_event_file_count) { ASSERT(0 == uv_fs_event_stop(handle)); uv_close((uv_handle_t*) handle, close_cb); } }
int DirWatcher::shutdown() { int r = 0; if (NULL == loop) { RX_WARNING("Asking to shutdown, but loop is NULL. Did you call init()?"); return -1; } /* stop listening for dir changes.*/ r = uv_fs_event_stop(&fs_event); if (0 != r) { RX_ERROR("Error while trying to stop the fs_event: %s", uv_strerror(r)); } directory.clear(); loop = NULL; user = NULL; on_rename = NULL; return 0; }
void uv__fs_event_close(uv_fs_event_t* handle) { uv_fs_event_stop(handle); }
/* _unix_update_file(): update file, producing list of changes * * when scanning through files, if dry, do nothing. otherwise, mark as * dry, then check if file exists. if not, remove self from node list * and add path plus sig to %into event. otherwise, read the file and * get a mug checksum. if same as mug_w, move on. otherwise, overwrite * mug_w with new mug and add path plus data to %into event. */ static u3_noun _unix_update_file(u3_ufil* fil_u) { c3_assert( c3n == fil_u->dir ); if ( c3y == fil_u->dry ) { return u3_nul; } fil_u->dry = c3y; struct stat buf_u; c3_i fid_i = open(fil_u->pax_c, O_RDONLY, 0644); c3_ws len_ws, red_ws; c3_y* dat_y; if ( fid_i < 0 || fstat(fid_i, &buf_u) < 0 ) { if ( ENOENT == errno ) { return u3nc(u3nc(_unix_string_to_path(fil_u->pax_c), u3_nul), u3_nul); } else { uL(fprintf(uH, "error opening file %s: %s\r\n", fil_u->pax_c, strerror(errno))); return u3_nul; } } // So, if file gets deleted and then quickly re-added, like vim and // other editors do, we lose the notification. This is a bad thing, // so we always stop and restart the notification. uv_fs_event_stop(&fil_u->was_u); c3_w ret_w = uv_fs_event_start(&fil_u->was_u, _unix_fs_event_cb, fil_u->pax_c, 0); if ( 0 != ret_w ) { uL(fprintf(uH, "update file event start: %s\n", uv_strerror(ret_w))); c3_assert(0); } len_ws = buf_u.st_size; dat_y = c3_malloc(len_ws); red_ws = read(fid_i, dat_y, len_ws); if ( close(fid_i) < 0 ) { uL(fprintf(uH, "error closing file %s: %s\r\n", fil_u->pax_c, strerror(errno))); } if ( len_ws != red_ws ) { if ( red_ws < 0 ) { uL(fprintf(uH, "error reading file %s: %s\r\n", fil_u->pax_c, strerror(errno))); } else { uL(fprintf(uH, "wrong # of bytes read in file %s: %d %d\r\n", fil_u->pax_c, len_ws, red_ws)); } free(dat_y); return u3_nul; } else { c3_w mug_w = u3r_mug_bytes(dat_y, len_ws); if ( mug_w == fil_u->mug_w ) { free(dat_y); return u3_nul; } else if ( mug_w == fil_u->gum_w ) { fil_u->mug_w = mug_w; free(dat_y); return u3_nul; } else { fil_u->mug_w = mug_w; u3_noun pax = _unix_string_to_path(fil_u->pax_c); u3_noun mim = u3nt(c3__text, u3i_string("plain"), u3_nul); u3_noun dat = u3nt(mim, len_ws, u3i_bytes(len_ws, dat_y)); free(dat_y); return u3nc(u3nt(pax, u3_nul, dat), u3_nul); } } }