Ejemplo n.º 1
0
static int luv_fs_poll_start(lua_State* L) {
  uv_fs_poll_t* handle = luv_check_fs_poll(L, 1);
  const char* path = luaL_checkstring(L, 2);
  unsigned int interval = luaL_checkinteger(L, 3);
  int ret;
  luv_check_callback(L, handle->data, LUV_FS_POLL, 4);
  ret = uv_fs_poll_start(handle, luv_fs_poll_cb, path, interval);
  if (ret < 0) return luv_error(L, ret);
  lua_pushinteger(L, ret);
  return 1;
}
Ejemplo n.º 2
0
/*
 * Class:     com_oracle_libuv_handles_FilePollHandle
 * Method:    _start
 * Signature: (JLjava/lang/String;ZILcom/oracle/libuv/Stats;Lcom/oracle/libuv/Stats;)I
 */
JNIEXPORT jint JNICALL Java_com_oracle_libuv_handles_FilePollHandle__1start
  (JNIEnv *env, jobject that, jlong fs_poll_ptr, jstring path, jboolean persistent, jint interval, jobject previous, jobject current) {

  assert(fs_poll_ptr);
  uv_fs_poll_t* handle = reinterpret_cast<uv_fs_poll_t*>(fs_poll_ptr);

  FilePollCallbacks* cb = reinterpret_cast<FilePollCallbacks*>(handle->data);
  cb->set_stats(previous, current);

  const char* cpath = env->GetStringUTFChars(path, 0);
  if (!persistent) {
      uv_unref(reinterpret_cast<uv_handle_t*>(fs_poll_ptr));
  }

  int r = uv_fs_poll_start(handle, _poll_cb, cpath, interval);
  if (r) {
    ThrowException(env, handle->loop, "uv_fs_poll_start");
  }
  env->ReleaseStringUTFChars(path, cpath);
  return r;
}
Ejemplo n.º 3
0
DLLEXPORT int jl_fs_poll_start(uv_fs_poll_t* handle, char *file, uint32_t interval)
{
    return uv_fs_poll_start(handle,&jl_fspollcb,file,interval);
}