noderb 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/noderb_extension/libuv/AUTHORS +11 -1
- data/ext/noderb_extension/libuv/LICENSE +0 -8
- data/ext/noderb_extension/libuv/Makefile +5 -5
- data/ext/noderb_extension/libuv/README +11 -6
- data/ext/noderb_extension/libuv/common.gypi +158 -7
- data/ext/noderb_extension/libuv/config-unix.mk +34 -26
- data/ext/noderb_extension/libuv/gyp_uv +22 -4
- data/ext/noderb_extension/libuv/include/{eio.h → uv-private/eio.h} +2 -2
- data/ext/noderb_extension/libuv/include/{uv-unix.h → uv-private/uv-unix.h} +40 -0
- data/ext/noderb_extension/libuv/include/{uv-win.h → uv-private/uv-win.h} +96 -14
- data/ext/noderb_extension/libuv/include/uv.h +508 -83
- data/ext/noderb_extension/libuv/src/unix/cares.c +185 -0
- data/ext/noderb_extension/libuv/src/unix/core.c +828 -0
- data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_darwin.h +4 -0
- data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_linux.h +5 -15
- data/ext/noderb_extension/libuv/src/{eio → unix/eio}/eio.c +23 -2
- data/ext/noderb_extension/libuv/src/unix/error.c +102 -0
- data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_linux.h +26 -15
- data/ext/noderb_extension/libuv/src/unix/fs.c +562 -0
- data/ext/noderb_extension/libuv/src/unix/internal.h +75 -0
- data/ext/noderb_extension/libuv/src/unix/pipe.c +282 -0
- data/ext/noderb_extension/libuv/src/unix/process.c +287 -0
- data/ext/noderb_extension/libuv/src/unix/stream.c +727 -0
- data/ext/noderb_extension/libuv/src/unix/tcp.c +226 -0
- data/ext/noderb_extension/libuv/src/unix/udp.c +524 -0
- data/ext/noderb_extension/libuv/src/{uv-eio.c → unix/uv-eio.c} +48 -27
- data/ext/noderb_extension/libuv/src/{uv-eio.h → unix/uv-eio.h} +1 -1
- data/ext/noderb_extension/libuv/src/uv-common.c +24 -14
- data/ext/noderb_extension/libuv/src/uv-common.h +12 -7
- data/ext/noderb_extension/libuv/src/win/async.c +14 -16
- data/ext/noderb_extension/libuv/src/win/cares.c +64 -79
- data/ext/noderb_extension/libuv/src/win/core.c +105 -53
- data/ext/noderb_extension/libuv/src/win/error.c +23 -13
- data/ext/noderb_extension/libuv/src/win/fs.c +807 -0
- data/ext/noderb_extension/libuv/src/win/getaddrinfo.c +61 -41
- data/ext/noderb_extension/libuv/src/win/handle.c +56 -30
- data/ext/noderb_extension/libuv/src/win/internal.h +134 -95
- data/ext/noderb_extension/libuv/src/win/loop-watcher.c +21 -18
- data/ext/noderb_extension/libuv/src/win/pipe.c +313 -158
- data/ext/noderb_extension/libuv/src/win/process.c +117 -131
- data/ext/noderb_extension/libuv/src/win/req.c +55 -31
- data/ext/noderb_extension/libuv/src/win/stdio.c +5 -5
- data/ext/noderb_extension/libuv/src/win/stream.c +19 -14
- data/ext/noderb_extension/libuv/src/win/tcp.c +278 -336
- data/ext/noderb_extension/libuv/src/win/threadpool.c +73 -0
- data/ext/noderb_extension/libuv/src/win/timer.c +44 -37
- data/ext/noderb_extension/libuv/src/win/udp.c +592 -0
- data/ext/noderb_extension/libuv/src/win/util.c +20 -6
- data/ext/noderb_extension/libuv/src/win/winapi.c +23 -6
- data/ext/noderb_extension/libuv/src/win/winapi.h +4206 -0
- data/ext/noderb_extension/libuv/src/win/winsock.c +270 -0
- data/ext/noderb_extension/libuv/src/win/winsock.h +134 -0
- data/ext/noderb_extension/libuv/test/benchmark-ares.c +10 -6
- data/ext/noderb_extension/libuv/test/benchmark-getaddrinfo.c +10 -7
- data/ext/noderb_extension/libuv/test/benchmark-list.h +21 -0
- data/ext/noderb_extension/libuv/test/benchmark-ping-pongs.c +11 -7
- data/ext/noderb_extension/libuv/test/benchmark-pound.c +147 -58
- data/ext/noderb_extension/libuv/test/benchmark-pump.c +29 -23
- data/ext/noderb_extension/libuv/test/benchmark-spawn.c +13 -10
- data/ext/noderb_extension/libuv/test/benchmark-udp-packet-storm.c +250 -0
- data/ext/noderb_extension/libuv/test/dns-server.c +11 -6
- data/ext/noderb_extension/libuv/test/echo-server.c +30 -22
- data/ext/noderb_extension/libuv/test/test-async.c +3 -3
- data/ext/noderb_extension/libuv/test/test-callback-stack.c +6 -6
- data/ext/noderb_extension/libuv/test/test-connection-fail.c +6 -5
- data/ext/noderb_extension/libuv/test/test-delayed-accept.c +13 -13
- data/ext/noderb_extension/libuv/test/test-fs.c +715 -0
- data/ext/noderb_extension/libuv/test/test-getaddrinfo.c +11 -8
- data/ext/noderb_extension/libuv/test/test-gethostbyname.c +8 -9
- data/ext/noderb_extension/libuv/test/test-getsockname.c +142 -16
- data/ext/noderb_extension/libuv/test/test-idle.c +4 -3
- data/ext/noderb_extension/libuv/test/test-list.h +29 -2
- data/ext/noderb_extension/libuv/test/test-loop-handles.c +9 -8
- data/ext/noderb_extension/libuv/test/test-ping-pong.c +9 -9
- data/ext/noderb_extension/libuv/test/test-pipe-bind-error.c +18 -14
- data/ext/noderb_extension/libuv/test/test-ref.c +17 -16
- data/ext/noderb_extension/libuv/test/test-shutdown-eof.c +5 -5
- data/ext/noderb_extension/libuv/test/test-spawn.c +17 -17
- data/ext/noderb_extension/libuv/test/test-tcp-bind-error.c +24 -18
- data/ext/noderb_extension/libuv/test/test-tcp-bind6-error.c +19 -14
- data/ext/noderb_extension/libuv/test/test-tcp-writealot.c +6 -5
- data/ext/noderb_extension/libuv/test/test-threadpool.c +59 -0
- data/ext/noderb_extension/libuv/test/test-timer-again.c +15 -12
- data/ext/noderb_extension/libuv/test/test-timer.c +8 -8
- data/ext/noderb_extension/libuv/test/test-udp-dgram-too-big.c +88 -0
- data/ext/noderb_extension/libuv/test/test-udp-ipv6.c +158 -0
- data/ext/noderb_extension/libuv/test/test-udp-send-and-recv.c +210 -0
- data/ext/noderb_extension/libuv/{all.gyp → uv.gyp} +75 -77
- data/ext/noderb_extension/libuv/vcbuild.bat +93 -0
- data/ext/noderb_extension/noderb.c +13 -0
- data/ext/noderb_extension/noderb_common.h +2 -1
- data/ext/noderb_extension/noderb_defer.c +54 -0
- data/ext/noderb_extension/noderb_defer.h +15 -0
- data/ext/noderb_extension/noderb_dns.c +1 -1
- data/ext/noderb_extension/noderb_fs.c +277 -0
- data/ext/noderb_extension/noderb_fs.h +27 -0
- data/ext/noderb_extension/noderb_process.c +5 -5
- data/ext/noderb_extension/noderb_tcp.c +10 -6
- data/ext/noderb_extension/noderb_timers.c +1 -1
- data/ext/noderb_extension/noderb_tools.c +42 -8
- data/ext/noderb_extension/noderb_tools.h +3 -1
- data/lib/noderb/defer.rb +25 -0
- data/lib/noderb/file.rb +119 -0
- data/lib/noderb/fs.rb +72 -0
- data/lib/noderb/version.rb +1 -1
- data/lib/noderb.rb +8 -0
- metadata +102 -266
- data/ext/noderb_extension/libuv/BSDmakefile +0 -2
- data/ext/noderb_extension/libuv/create-msvs-files.bat +0 -21
- data/ext/noderb_extension/libuv/deps/pthread-win32/ANNOUNCE +0 -482
- data/ext/noderb_extension/libuv/deps/pthread-win32/BUGS +0 -141
- data/ext/noderb_extension/libuv/deps/pthread-win32/Bmakefile +0 -268
- data/ext/noderb_extension/libuv/deps/pthread-win32/CONTRIBUTORS +0 -140
- data/ext/noderb_extension/libuv/deps/pthread-win32/COPYING +0 -150
- data/ext/noderb_extension/libuv/deps/pthread-win32/COPYING.LIB +0 -504
- data/ext/noderb_extension/libuv/deps/pthread-win32/ChangeLog +0 -5194
- data/ext/noderb_extension/libuv/deps/pthread-win32/FAQ +0 -451
- data/ext/noderb_extension/libuv/deps/pthread-win32/GNUmakefile +0 -593
- data/ext/noderb_extension/libuv/deps/pthread-win32/MAINTAINERS +0 -4
- data/ext/noderb_extension/libuv/deps/pthread-win32/Makefile +0 -516
- data/ext/noderb_extension/libuv/deps/pthread-win32/NEWS +0 -1245
- data/ext/noderb_extension/libuv/deps/pthread-win32/Nmakefile +0 -24
- data/ext/noderb_extension/libuv/deps/pthread-win32/Nmakefile.tests +0 -260
- data/ext/noderb_extension/libuv/deps/pthread-win32/PROGRESS +0 -4
- data/ext/noderb_extension/libuv/deps/pthread-win32/README +0 -601
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.Borland +0 -57
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.CV +0 -3036
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.NONPORTABLE +0 -783
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.Watcom +0 -62
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.WinCE +0 -6
- data/ext/noderb_extension/libuv/deps/pthread-win32/TODO +0 -7
- data/ext/noderb_extension/libuv/deps/pthread-win32/WinCE-PORT +0 -222
- data/ext/noderb_extension/libuv/deps/pthread-win32/attr.c +0 -53
- data/ext/noderb_extension/libuv/deps/pthread-win32/autostatic.c +0 -69
- data/ext/noderb_extension/libuv/deps/pthread-win32/barrier.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/build/all.gyp +0 -207
- data/ext/noderb_extension/libuv/deps/pthread-win32/builddmc.bat +0 -9
- data/ext/noderb_extension/libuv/deps/pthread-win32/cancel.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/cleanup.c +0 -148
- data/ext/noderb_extension/libuv/deps/pthread-win32/condvar.c +0 -50
- data/ext/noderb_extension/libuv/deps/pthread-win32/config.h +0 -153
- data/ext/noderb_extension/libuv/deps/pthread-win32/context.h +0 -74
- data/ext/noderb_extension/libuv/deps/pthread-win32/create.c +0 -308
- data/ext/noderb_extension/libuv/deps/pthread-win32/dll.c +0 -92
- data/ext/noderb_extension/libuv/deps/pthread-win32/errno.c +0 -94
- data/ext/noderb_extension/libuv/deps/pthread-win32/exit.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/fork.c +0 -39
- data/ext/noderb_extension/libuv/deps/pthread-win32/global.c +0 -107
- data/ext/noderb_extension/libuv/deps/pthread-win32/implement.h +0 -944
- data/ext/noderb_extension/libuv/deps/pthread-win32/misc.c +0 -50
- data/ext/noderb_extension/libuv/deps/pthread-win32/mutex.c +0 -62
- data/ext/noderb_extension/libuv/deps/pthread-win32/need_errno.h +0 -145
- data/ext/noderb_extension/libuv/deps/pthread-win32/nonportable.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/private.c +0 -54
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.c +0 -66
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.dsp +0 -142
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.dsw +0 -29
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.h +0 -1368
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_destroy.c +0 -79
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getdetachstate.c +0 -86
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getinheritsched.c +0 -51
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getschedparam.c +0 -52
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getschedpolicy.c +0 -61
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getscope.c +0 -54
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getstackaddr.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getstacksize.c +0 -100
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_init.c +0 -117
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setdetachstate.c +0 -91
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setinheritsched.c +0 -57
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setschedparam.c +0 -63
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setschedpolicy.c +0 -55
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setscope.c +0 -62
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setstackaddr.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setstacksize.c +0 -110
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_destroy.c +0 -103
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_init.c +0 -69
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_wait.c +0 -104
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_destroy.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_getpshared.c +0 -95
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_init.c +0 -85
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_setpshared.c +0 -119
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cancel.c +0 -189
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_destroy.c +0 -253
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_init.c +0 -167
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_signal.c +0 -231
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_wait.c +0 -567
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_destroy.c +0 -86
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_getpshared.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_init.c +0 -87
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_setpshared.c +0 -117
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_delay_np.c +0 -172
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_detach.c +0 -136
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_equal.c +0 -76
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_exit.c +0 -106
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getconcurrency.c +0 -45
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getschedparam.c +0 -75
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getspecific.c +0 -87
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getunique_np.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getw32threadhandle_np.c +0 -65
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_join.c +0 -157
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_key_create.c +0 -108
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_key_delete.c +0 -125
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_kill.c +0 -105
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_consistent.c +0 -187
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_destroy.c +0 -148
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_init.c +0 -130
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_lock.c +0 -269
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_timedlock.c +0 -324
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_trylock.c +0 -154
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_unlock.c +0 -175
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_destroy.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getkind_np.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getpshared.c +0 -95
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getrobust.c +0 -113
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_gettype.c +0 -56
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_init.c +0 -86
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setkind_np.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setpshared.c +0 -119
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setrobust.c +0 -119
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_settype.c +0 -143
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_num_processors_np.c +0 -56
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_once.c +0 -79
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_destroy.c +0 -143
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_init.c +0 -109
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_rdlock.c +0 -102
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_timedrdlock.c +0 -109
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_timedwrlock.c +0 -139
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_tryrdlock.c +0 -102
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_trywrlock.c +0 -122
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_unlock.c +0 -93
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_wrlock.c +0 -133
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_destroy.c +0 -84
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_getpshared.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_init.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_setpshared.c +0 -120
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_self.c +0 -141
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setcancelstate.c +0 -125
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setcanceltype.c +0 -126
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setconcurrency.c +0 -53
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setschedparam.c +0 -123
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setspecific.c +0 -167
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_destroy.c +0 -111
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_init.c +0 -123
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_lock.c +0 -80
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_trylock.c +0 -77
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_unlock.c +0 -71
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_testcancel.c +0 -103
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_timechange_handler_np.c +0 -108
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_win32_attach_detach_np.c +0 -258
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_MCS_lock.c +0 -278
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_callUserDestroyRoutines.c +0 -232
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_calloc.c +0 -56
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_cond_check_need_init.c +0 -78
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_getprocessors.c +0 -91
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_is_attr.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_mutex_check_need_init.c +0 -92
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_new.c +0 -94
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_processInitialize.c +0 -92
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_processTerminate.c +0 -105
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_relmillisecs.c +0 -132
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_reuse.c +0 -151
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_rwlock_cancelwrwait.c +0 -50
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_rwlock_check_need_init.c +0 -77
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_semwait.c +0 -135
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_spinlock_check_need_init.c +0 -78
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_threadDestroy.c +0 -79
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_threadStart.c +0 -357
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_throw.c +0 -189
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_timespec.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_tkAssocCreate.c +0 -118
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_tkAssocDestroy.c +0 -114
- data/ext/noderb_extension/libuv/deps/pthread-win32/rwlock.c +0 -51
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched.c +0 -53
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched.h +0 -183
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_get_priority_max.c +0 -134
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_get_priority_min.c +0 -135
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_getscheduler.c +0 -71
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_setscheduler.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_yield.c +0 -71
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_close.c +0 -58
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_destroy.c +0 -144
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_getvalue.c +0 -110
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_init.c +0 -169
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_open.c +0 -58
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_post.c +0 -128
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_post_multiple.c +0 -142
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_timedwait.c +0 -238
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_trywait.c +0 -117
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_unlink.c +0 -58
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_wait.c +0 -187
- data/ext/noderb_extension/libuv/deps/pthread-win32/semaphore.c +0 -69
- data/ext/noderb_extension/libuv/deps/pthread-win32/semaphore.h +0 -169
- data/ext/noderb_extension/libuv/deps/pthread-win32/signal.c +0 -179
- data/ext/noderb_extension/libuv/deps/pthread-win32/spin.c +0 -46
- data/ext/noderb_extension/libuv/deps/pthread-win32/sync.c +0 -43
- data/ext/noderb_extension/libuv/deps/pthread-win32/tsd.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/version.rc +0 -388
- data/ext/noderb_extension/libuv/deps/pthread-win32/w32_CancelableWait.c +0 -161
- data/ext/noderb_extension/libuv/doc/iocp-links.html +0 -574
- data/ext/noderb_extension/libuv/src/uv-unix.c +0 -2421
- data/ext/noderb_extension/libuv/src/win/ntdll.h +0 -130
- /data/ext/noderb_extension/libuv/include/{ev.h → uv-private/ev.h} +0 -0
- /data/ext/noderb_extension/libuv/include/{ngx-queue.h → uv-private/ngx-queue.h} +0 -0
- /data/ext/noderb_extension/libuv/include/{tree.h → uv-private/tree.h} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-cygwin.c → unix/cygwin.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-darwin.c → unix/darwin.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/Changes +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/LICENSE +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/Makefile.am +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/aclocal.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/autogen.sh +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config.h.in +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_cygwin.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_freebsd.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_sunos.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/configure.ac +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/demo.c +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/ecb.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/eio.3 +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/eio.pod +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/libeio.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/xthread.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/Changes +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/LICENSE +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/Makefile.am +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/Makefile.in +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/README +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/aclocal.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/autogen.sh +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config.guess +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config.h.in +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config.sub +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_cygwin.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_darwin.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_freebsd.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_sunos.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/configure +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/configure.ac +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/depcomp +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev++.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev.3 +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev.pod +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_epoll.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_kqueue.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_poll.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_port.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_select.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_vars.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_win32.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_wrap.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/event.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/event.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/install-sh +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/libev.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ltmain.sh +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/missing +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/mkinstalldirs +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-freebsd.c → unix/freebsd.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-linux.c → unix/linux.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-sunos.c → unix/sunos.c} +0 -0
@@ -0,0 +1,807 @@
|
|
1
|
+
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
2
|
+
*
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
* of this software and associated documentation files (the "Software"), to
|
5
|
+
* deal in the Software without restriction, including without limitation the
|
6
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
* sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
* furnished to do so, subject to the following conditions:
|
9
|
+
*
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
11
|
+
* all copies or substantial portions of the Software.
|
12
|
+
*
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
18
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
19
|
+
* IN THE SOFTWARE.
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include <assert.h>
|
23
|
+
#include <malloc.h>
|
24
|
+
#include <direct.h>
|
25
|
+
#include <fcntl.h>
|
26
|
+
#include <io.h>
|
27
|
+
#include <sys/stat.h>
|
28
|
+
#include <sys/utime.h>
|
29
|
+
#include <stdio.h>
|
30
|
+
|
31
|
+
#include "uv.h"
|
32
|
+
#include "internal.h"
|
33
|
+
|
34
|
+
#define UV_FS_ASYNC_QUEUED 0x0001
|
35
|
+
#define UV_FS_FREE_ARG0 0x0002
|
36
|
+
#define UV_FS_FREE_ARG1 0x0004
|
37
|
+
#define UV_FS_FREE_PTR 0x0008
|
38
|
+
#define UV_FS_CLEANEDUP 0x0010
|
39
|
+
|
40
|
+
#define STRDUP_ARG(req, i) \
|
41
|
+
req->arg##i = (void*)strdup((const char*)req->arg##i); \
|
42
|
+
if (!req->arg##i) { \
|
43
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); \
|
44
|
+
} \
|
45
|
+
req->flags |= UV_FS_FREE_ARG##i;
|
46
|
+
|
47
|
+
#define WRAP_REQ_ARGS1(req, a0) \
|
48
|
+
req->arg0 = (void*)a0;
|
49
|
+
|
50
|
+
#define WRAP_REQ_ARGS2(req, a0, a1) \
|
51
|
+
WRAP_REQ_ARGS1(req, a0) \
|
52
|
+
req->arg1 = (void*)a1;
|
53
|
+
|
54
|
+
#define WRAP_REQ_ARGS3(req, a0, a1, a2) \
|
55
|
+
WRAP_REQ_ARGS2(req, a0, a1) \
|
56
|
+
req->arg2 = (void*)a2;
|
57
|
+
|
58
|
+
#define WRAP_REQ_ARGS4(req, a0, a1, a2, a3) \
|
59
|
+
WRAP_REQ_ARGS3(req, a0, a1, a2) \
|
60
|
+
req->arg3 = (void*)a3;
|
61
|
+
|
62
|
+
#define QUEUE_FS_TP_JOB(loop, req) \
|
63
|
+
if (!QueueUserWorkItem(&uv_fs_thread_proc, \
|
64
|
+
req, \
|
65
|
+
WT_EXECUTELONGFUNCTION)) { \
|
66
|
+
uv_set_sys_error((loop), GetLastError()); \
|
67
|
+
return -1; \
|
68
|
+
} \
|
69
|
+
req->flags |= UV_FS_ASYNC_QUEUED; \
|
70
|
+
uv_ref((loop));
|
71
|
+
|
72
|
+
|
73
|
+
void uv_fs_init() {
|
74
|
+
_fmode = _O_BINARY;
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
static void uv_fs_req_init_async(uv_loop_t* loop, uv_fs_t* req,
|
79
|
+
uv_fs_type fs_type, uv_fs_cb cb) {
|
80
|
+
uv_req_init(loop, (uv_req_t*) req);
|
81
|
+
req->type = UV_FS;
|
82
|
+
req->loop = loop;
|
83
|
+
req->flags = 0;
|
84
|
+
req->fs_type = fs_type;
|
85
|
+
req->cb = cb;
|
86
|
+
req->result = 0;
|
87
|
+
req->ptr = NULL;
|
88
|
+
req->errorno = 0;
|
89
|
+
memset(&req->overlapped, 0, sizeof(req->overlapped));
|
90
|
+
}
|
91
|
+
|
92
|
+
|
93
|
+
static void uv_fs_req_init_sync(uv_loop_t* loop, uv_fs_t* req,
|
94
|
+
uv_fs_type fs_type) {
|
95
|
+
uv_req_init(loop, (uv_req_t*) req);
|
96
|
+
req->type = UV_FS;
|
97
|
+
req->loop = loop;
|
98
|
+
req->flags = 0;
|
99
|
+
req->fs_type = fs_type;
|
100
|
+
req->result = 0;
|
101
|
+
req->ptr = NULL;
|
102
|
+
req->errorno = 0;
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
void fs__open(uv_fs_t* req, const char* path, int flags, int mode) {
|
107
|
+
int result = _open(path, flags, mode);
|
108
|
+
SET_REQ_RESULT(req, result);
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
void fs__close(uv_fs_t* req, uv_file file) {
|
113
|
+
int result = _close(file);
|
114
|
+
SET_REQ_RESULT(req, result);
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
|
119
|
+
off_t offset) {
|
120
|
+
int result = 0;
|
121
|
+
|
122
|
+
if (offset != -1) {
|
123
|
+
result = _lseek(file, offset, SEEK_SET);
|
124
|
+
}
|
125
|
+
|
126
|
+
if (result != -1) {
|
127
|
+
result = _read(file, buf, length);
|
128
|
+
}
|
129
|
+
|
130
|
+
SET_REQ_RESULT(req, result);
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
|
135
|
+
off_t offset) {
|
136
|
+
int result = 0;
|
137
|
+
|
138
|
+
if (offset != -1) {
|
139
|
+
result = _lseek(file, offset, SEEK_SET);
|
140
|
+
}
|
141
|
+
|
142
|
+
if (result != -1) {
|
143
|
+
result = _write(file, buf, length);
|
144
|
+
}
|
145
|
+
|
146
|
+
SET_REQ_RESULT(req, result);
|
147
|
+
}
|
148
|
+
|
149
|
+
|
150
|
+
void fs__unlink(uv_fs_t* req, const char* path) {
|
151
|
+
int result = _unlink(path);
|
152
|
+
SET_REQ_RESULT(req, result);
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
void fs__mkdir(uv_fs_t* req, const char* path, int mode) {
|
157
|
+
int result = _mkdir(path);
|
158
|
+
SET_REQ_RESULT(req, result);
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
void fs__rmdir(uv_fs_t* req, const char* path) {
|
163
|
+
int result = _rmdir(path);
|
164
|
+
SET_REQ_RESULT(req, result);
|
165
|
+
}
|
166
|
+
|
167
|
+
|
168
|
+
void fs__readdir(uv_fs_t* req, const char* path, int flags) {
|
169
|
+
int result;
|
170
|
+
char* buf, *ptr, *name;
|
171
|
+
HANDLE dir;
|
172
|
+
WIN32_FIND_DATAA ent = {0};
|
173
|
+
size_t len = strlen(path);
|
174
|
+
size_t buf_size = 4096;
|
175
|
+
const char* fmt = !len ? "./*"
|
176
|
+
: (path[len - 1] == '/' || path[len - 1] == '\\') ? "%s*"
|
177
|
+
: "%s\\*";
|
178
|
+
|
179
|
+
char* path2 = (char*)malloc(len + 4);
|
180
|
+
if (!path2) {
|
181
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
182
|
+
}
|
183
|
+
|
184
|
+
sprintf(path2, fmt, path);
|
185
|
+
dir = FindFirstFileA(path2, &ent);
|
186
|
+
free(path2);
|
187
|
+
|
188
|
+
if(dir == INVALID_HANDLE_VALUE) {
|
189
|
+
result = -1;
|
190
|
+
goto done;
|
191
|
+
}
|
192
|
+
|
193
|
+
buf = (char*)malloc(buf_size);
|
194
|
+
if (!buf) {
|
195
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
196
|
+
}
|
197
|
+
|
198
|
+
ptr = buf;
|
199
|
+
result = 0;
|
200
|
+
|
201
|
+
do {
|
202
|
+
name = ent.cFileName;
|
203
|
+
|
204
|
+
if (name[0] != '.' || (name[1] && (name[1] != '.' || name[2]))) {
|
205
|
+
len = strlen(name);
|
206
|
+
|
207
|
+
while ((ptr - buf) + len + 1 > buf_size) {
|
208
|
+
buf_size *= 2;
|
209
|
+
path2 = buf;
|
210
|
+
buf = (char*)realloc(buf, buf_size);
|
211
|
+
if (!buf) {
|
212
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "realloc");
|
213
|
+
}
|
214
|
+
|
215
|
+
ptr = buf + (ptr - path2);
|
216
|
+
}
|
217
|
+
|
218
|
+
strcpy(ptr, name);
|
219
|
+
ptr += len + 1;
|
220
|
+
result++;
|
221
|
+
}
|
222
|
+
} while(FindNextFileA(dir, &ent));
|
223
|
+
|
224
|
+
FindClose(dir);
|
225
|
+
|
226
|
+
req->ptr = buf;
|
227
|
+
req->flags |= UV_FS_FREE_PTR;
|
228
|
+
|
229
|
+
done:
|
230
|
+
SET_REQ_RESULT(req, result);
|
231
|
+
}
|
232
|
+
|
233
|
+
|
234
|
+
void fs__stat(uv_fs_t* req, const char* path) {
|
235
|
+
int result;
|
236
|
+
|
237
|
+
result = _stat(path, &req->stat);
|
238
|
+
if (result == -1) {
|
239
|
+
req->ptr = NULL;
|
240
|
+
} else {
|
241
|
+
req->ptr = &req->stat;
|
242
|
+
}
|
243
|
+
|
244
|
+
SET_REQ_RESULT(req, result);
|
245
|
+
}
|
246
|
+
|
247
|
+
|
248
|
+
void fs__fstat(uv_fs_t* req, uv_file file) {
|
249
|
+
int result;
|
250
|
+
|
251
|
+
result = _fstat(file, &req->stat);
|
252
|
+
if (result == -1) {
|
253
|
+
req->ptr = NULL;
|
254
|
+
} else {
|
255
|
+
req->ptr = &req->stat;
|
256
|
+
}
|
257
|
+
|
258
|
+
SET_REQ_RESULT(req, result);
|
259
|
+
}
|
260
|
+
|
261
|
+
|
262
|
+
void fs__rename(uv_fs_t* req, const char* path, const char* new_path) {
|
263
|
+
int result = rename(path, new_path);
|
264
|
+
SET_REQ_RESULT(req, result);
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
void fs__fsync(uv_fs_t* req, uv_file file) {
|
269
|
+
int result = FlushFileBuffers((HANDLE)_get_osfhandle(file)) ? 0 : -1;
|
270
|
+
SET_REQ_RESULT(req, result);
|
271
|
+
}
|
272
|
+
|
273
|
+
|
274
|
+
void fs__ftruncate(uv_fs_t* req, uv_file file, off_t offset) {
|
275
|
+
int result = _chsize(file, offset);
|
276
|
+
SET_REQ_RESULT(req, result);
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
void fs__sendfile(uv_fs_t* req, uv_file out_file, uv_file in_file,
|
281
|
+
off_t in_offset, size_t length) {
|
282
|
+
const size_t max_buf_size = 65536;
|
283
|
+
size_t buf_size = length < max_buf_size ? length : max_buf_size;
|
284
|
+
int n, result = 0;
|
285
|
+
char* buf = (char*)malloc(buf_size);
|
286
|
+
if (!buf) {
|
287
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
288
|
+
}
|
289
|
+
|
290
|
+
if (in_offset != -1) {
|
291
|
+
result = _lseek(in_file, in_offset, SEEK_SET);
|
292
|
+
}
|
293
|
+
|
294
|
+
if (result != -1) {
|
295
|
+
while (length > 0) {
|
296
|
+
n = _read(in_file, buf, length < buf_size ? length : buf_size);
|
297
|
+
if (n == 0) {
|
298
|
+
break;
|
299
|
+
} else if (n == -1) {
|
300
|
+
result = -1;
|
301
|
+
break;
|
302
|
+
}
|
303
|
+
|
304
|
+
length -= n;
|
305
|
+
|
306
|
+
n = _write(out_file, buf, n);
|
307
|
+
if (n == -1) {
|
308
|
+
result = -1;
|
309
|
+
break;
|
310
|
+
}
|
311
|
+
|
312
|
+
result += n;
|
313
|
+
}
|
314
|
+
}
|
315
|
+
|
316
|
+
SET_REQ_RESULT(req, result);
|
317
|
+
}
|
318
|
+
|
319
|
+
|
320
|
+
void fs__chmod(uv_fs_t* req, const char* path, int mode) {
|
321
|
+
int result = _chmod(path, mode);
|
322
|
+
SET_REQ_RESULT(req, result);
|
323
|
+
}
|
324
|
+
|
325
|
+
|
326
|
+
void fs__utime(uv_fs_t* req, const char* path, double atime, double mtime) {
|
327
|
+
int result;
|
328
|
+
struct _utimbuf b = {(time_t)atime, (time_t)mtime};
|
329
|
+
result = _utime(path, &b);
|
330
|
+
SET_REQ_RESULT(req, result);
|
331
|
+
}
|
332
|
+
|
333
|
+
|
334
|
+
void fs__futime(uv_fs_t* req, uv_file file, double atime, double mtime) {
|
335
|
+
int result;
|
336
|
+
struct _utimbuf b = {(time_t)atime, (time_t)mtime};
|
337
|
+
result = _futime(file, &b);
|
338
|
+
SET_REQ_RESULT(req, result);
|
339
|
+
}
|
340
|
+
|
341
|
+
|
342
|
+
static DWORD WINAPI uv_fs_thread_proc(void* parameter) {
|
343
|
+
uv_fs_t* req = (uv_fs_t*) parameter;
|
344
|
+
uv_loop_t* loop = req->loop;
|
345
|
+
|
346
|
+
assert(req != NULL);
|
347
|
+
assert(req->type == UV_FS);
|
348
|
+
|
349
|
+
switch (req->fs_type) {
|
350
|
+
case UV_FS_OPEN:
|
351
|
+
fs__open(req, (const char*)req->arg0, (int)req->arg1, (int)req->arg2);
|
352
|
+
break;
|
353
|
+
case UV_FS_CLOSE:
|
354
|
+
fs__close(req, (uv_file)req->arg0);
|
355
|
+
break;
|
356
|
+
case UV_FS_READ:
|
357
|
+
fs__read(req,
|
358
|
+
(uv_file) req->arg0,
|
359
|
+
req->arg1,
|
360
|
+
(size_t) req->arg2,
|
361
|
+
(off_t) req->arg3);
|
362
|
+
break;
|
363
|
+
case UV_FS_WRITE:
|
364
|
+
fs__write(req,
|
365
|
+
(uv_file)req->arg0,
|
366
|
+
req->arg1,
|
367
|
+
(size_t) req->arg2,
|
368
|
+
(off_t) req->arg3);
|
369
|
+
break;
|
370
|
+
case UV_FS_UNLINK:
|
371
|
+
fs__unlink(req, (const char*)req->arg0);
|
372
|
+
break;
|
373
|
+
case UV_FS_MKDIR:
|
374
|
+
fs__mkdir(req, (const char*)req->arg0, (int)req->arg1);
|
375
|
+
break;
|
376
|
+
case UV_FS_RMDIR:
|
377
|
+
fs__rmdir(req, (const char*)req->arg0);
|
378
|
+
break;
|
379
|
+
case UV_FS_READDIR:
|
380
|
+
fs__readdir(req, (const char*)req->arg0, (int)req->arg1);
|
381
|
+
break;
|
382
|
+
case UV_FS_STAT:
|
383
|
+
fs__stat(req, (const char*)req->arg0);
|
384
|
+
break;
|
385
|
+
case UV_FS_FSTAT:
|
386
|
+
fs__fstat(req, (uv_file)req->arg0);
|
387
|
+
break;
|
388
|
+
case UV_FS_RENAME:
|
389
|
+
fs__rename(req, (const char*)req->arg0, (const char*)req->arg1);
|
390
|
+
break;
|
391
|
+
case UV_FS_FSYNC:
|
392
|
+
case UV_FS_FDATASYNC:
|
393
|
+
fs__fsync(req, (uv_file)req->arg0);
|
394
|
+
break;
|
395
|
+
case UV_FS_FTRUNCATE:
|
396
|
+
fs__ftruncate(req, (uv_file)req->arg0, (off_t)req->arg1);
|
397
|
+
break;
|
398
|
+
case UV_FS_SENDFILE:
|
399
|
+
fs__sendfile(req,
|
400
|
+
(uv_file) req->arg0,
|
401
|
+
(uv_file) req->arg1,
|
402
|
+
(off_t) req->arg2,
|
403
|
+
(size_t) req->arg3);
|
404
|
+
break;
|
405
|
+
case UV_FS_CHMOD:
|
406
|
+
fs__chmod(req, (const char*)req->arg0, (int)req->arg1);
|
407
|
+
break;
|
408
|
+
case UV_FS_UTIME:
|
409
|
+
fs__utime(req, (const char*)req->arg0, req->arg4, req->arg5);
|
410
|
+
break;
|
411
|
+
case UV_FS_FUTIME:
|
412
|
+
fs__futime(req, (uv_file)req->arg0, req->arg4, req->arg5);
|
413
|
+
break;
|
414
|
+
default:
|
415
|
+
assert(!"bad uv_fs_type");
|
416
|
+
}
|
417
|
+
|
418
|
+
POST_COMPLETION_FOR_REQ(loop, req);
|
419
|
+
|
420
|
+
return 0;
|
421
|
+
}
|
422
|
+
|
423
|
+
|
424
|
+
int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
|
425
|
+
int mode, uv_fs_cb cb) {
|
426
|
+
if (cb) {
|
427
|
+
uv_fs_req_init_async(loop, req, UV_FS_OPEN, cb);
|
428
|
+
WRAP_REQ_ARGS3(req, path, flags, mode);
|
429
|
+
STRDUP_ARG(req, 0);
|
430
|
+
QUEUE_FS_TP_JOB(loop, req);
|
431
|
+
} else {
|
432
|
+
uv_fs_req_init_sync(loop, req, UV_FS_OPEN);
|
433
|
+
fs__open(req, path, flags, mode);
|
434
|
+
}
|
435
|
+
|
436
|
+
return 0;
|
437
|
+
}
|
438
|
+
|
439
|
+
|
440
|
+
int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
441
|
+
if (cb) {
|
442
|
+
uv_fs_req_init_async(loop, req, UV_FS_CLOSE, cb);
|
443
|
+
WRAP_REQ_ARGS1(req, file);
|
444
|
+
QUEUE_FS_TP_JOB(loop, req);
|
445
|
+
} else {
|
446
|
+
uv_fs_req_init_sync(loop, req, UV_FS_CLOSE);
|
447
|
+
fs__close(req, file);
|
448
|
+
}
|
449
|
+
|
450
|
+
return 0;
|
451
|
+
}
|
452
|
+
|
453
|
+
|
454
|
+
int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
|
455
|
+
size_t length, off_t offset, uv_fs_cb cb) {
|
456
|
+
if (cb) {
|
457
|
+
uv_fs_req_init_async(loop, req, UV_FS_READ, cb);
|
458
|
+
WRAP_REQ_ARGS4(req, file, buf, length, offset);
|
459
|
+
QUEUE_FS_TP_JOB(loop, req);
|
460
|
+
} else {
|
461
|
+
uv_fs_req_init_sync(loop, req, UV_FS_READ);
|
462
|
+
fs__read(req, file, buf, length, offset);
|
463
|
+
}
|
464
|
+
|
465
|
+
return 0;
|
466
|
+
}
|
467
|
+
|
468
|
+
|
469
|
+
int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
|
470
|
+
size_t length, off_t offset, uv_fs_cb cb) {
|
471
|
+
if (cb) {
|
472
|
+
uv_fs_req_init_async(loop, req, UV_FS_WRITE, cb);
|
473
|
+
WRAP_REQ_ARGS4(req, file, buf, length, offset);
|
474
|
+
QUEUE_FS_TP_JOB(loop, req);
|
475
|
+
} else {
|
476
|
+
uv_fs_req_init_sync(loop, req, UV_FS_WRITE);
|
477
|
+
fs__write(req, file, buf, length, offset);
|
478
|
+
}
|
479
|
+
|
480
|
+
return 0;
|
481
|
+
}
|
482
|
+
|
483
|
+
|
484
|
+
int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
485
|
+
uv_fs_cb cb) {
|
486
|
+
if (cb) {
|
487
|
+
uv_fs_req_init_async(loop, req, UV_FS_UNLINK, cb);
|
488
|
+
WRAP_REQ_ARGS1(req, path);
|
489
|
+
STRDUP_ARG(req, 0);
|
490
|
+
QUEUE_FS_TP_JOB(loop, req);
|
491
|
+
} else {
|
492
|
+
uv_fs_req_init_sync(loop, req, UV_FS_UNLINK);
|
493
|
+
fs__unlink(req, path);
|
494
|
+
}
|
495
|
+
|
496
|
+
return 0;
|
497
|
+
}
|
498
|
+
|
499
|
+
|
500
|
+
int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode,
|
501
|
+
uv_fs_cb cb) {
|
502
|
+
if (cb) {
|
503
|
+
uv_fs_req_init_async(loop, req, UV_FS_MKDIR, cb);
|
504
|
+
WRAP_REQ_ARGS2(req, path, mode);
|
505
|
+
STRDUP_ARG(req, 0);
|
506
|
+
QUEUE_FS_TP_JOB(loop, req);
|
507
|
+
} else {
|
508
|
+
uv_fs_req_init_sync(loop, req, UV_FS_MKDIR);
|
509
|
+
fs__mkdir(req, path, mode);
|
510
|
+
}
|
511
|
+
|
512
|
+
return 0;
|
513
|
+
}
|
514
|
+
|
515
|
+
|
516
|
+
int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
517
|
+
if (cb) {
|
518
|
+
uv_fs_req_init_async(loop, req, UV_FS_RMDIR, cb);
|
519
|
+
WRAP_REQ_ARGS1(req, path);
|
520
|
+
STRDUP_ARG(req, 0);
|
521
|
+
QUEUE_FS_TP_JOB(loop, req);
|
522
|
+
} else {
|
523
|
+
uv_fs_req_init_sync(loop, req, UV_FS_RMDIR);
|
524
|
+
fs__rmdir(req, path);
|
525
|
+
}
|
526
|
+
|
527
|
+
return 0;
|
528
|
+
}
|
529
|
+
|
530
|
+
|
531
|
+
int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
|
532
|
+
uv_fs_cb cb) {
|
533
|
+
if (cb) {
|
534
|
+
uv_fs_req_init_async(loop, req, UV_FS_READDIR, cb);
|
535
|
+
WRAP_REQ_ARGS2(req, path, flags);
|
536
|
+
STRDUP_ARG(req, 0);
|
537
|
+
QUEUE_FS_TP_JOB(loop, req);
|
538
|
+
} else {
|
539
|
+
uv_fs_req_init_sync(loop, req, UV_FS_READDIR);
|
540
|
+
fs__readdir(req, path, flags);
|
541
|
+
}
|
542
|
+
|
543
|
+
return 0;
|
544
|
+
}
|
545
|
+
|
546
|
+
|
547
|
+
int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
548
|
+
assert(0 && "implement me");
|
549
|
+
return -1;
|
550
|
+
}
|
551
|
+
|
552
|
+
|
553
|
+
// uv_fs_readlink, uv_fs_fchmod, uv_fs_chown, uv_fs_fchown
|
554
|
+
int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
555
|
+
const char* new_path, uv_fs_cb cb) {
|
556
|
+
assert(0 && "implement me");
|
557
|
+
return -1;
|
558
|
+
}
|
559
|
+
|
560
|
+
|
561
|
+
int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
562
|
+
const char* new_path, uv_fs_cb cb) {
|
563
|
+
assert(0 && "implement me");
|
564
|
+
return -1;
|
565
|
+
}
|
566
|
+
|
567
|
+
|
568
|
+
int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
569
|
+
uv_fs_cb cb) {
|
570
|
+
assert(0 && "implement me");
|
571
|
+
return -1;
|
572
|
+
}
|
573
|
+
|
574
|
+
|
575
|
+
int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file, int mode,
|
576
|
+
uv_fs_cb cb) {
|
577
|
+
assert(0 && "implement me");
|
578
|
+
return -1;
|
579
|
+
}
|
580
|
+
|
581
|
+
|
582
|
+
int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, int uid,
|
583
|
+
int gid, uv_fs_cb cb) {
|
584
|
+
assert(0 && "implement me");
|
585
|
+
return -1;
|
586
|
+
}
|
587
|
+
|
588
|
+
|
589
|
+
int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, int uid,
|
590
|
+
int gid, uv_fs_cb cb) {
|
591
|
+
assert(0 && "implement me");
|
592
|
+
return -1;
|
593
|
+
}
|
594
|
+
|
595
|
+
|
596
|
+
int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
597
|
+
int len = strlen(path);
|
598
|
+
char* path2 = NULL;
|
599
|
+
int has_backslash = (path[len - 1] == '\\' || path[len - 1] == '/');
|
600
|
+
|
601
|
+
if (path[len - 1] == '\\' || path[len - 1] == '/') {
|
602
|
+
path2 = strdup(path);
|
603
|
+
if (!path2) {
|
604
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
605
|
+
}
|
606
|
+
|
607
|
+
path2[len - 1] = '\0';
|
608
|
+
}
|
609
|
+
|
610
|
+
if (cb) {
|
611
|
+
uv_fs_req_init_async(loop, req, UV_FS_STAT, cb);
|
612
|
+
if (path2) {
|
613
|
+
WRAP_REQ_ARGS1(req, path2);
|
614
|
+
req->flags |= UV_FS_FREE_ARG0;
|
615
|
+
} else {
|
616
|
+
WRAP_REQ_ARGS1(req, path);
|
617
|
+
STRDUP_ARG(req, 0);
|
618
|
+
}
|
619
|
+
|
620
|
+
QUEUE_FS_TP_JOB(loop, req);
|
621
|
+
} else {
|
622
|
+
uv_fs_req_init_sync(loop, req, UV_FS_STAT);
|
623
|
+
fs__stat(req, path2 ? path2 : path);
|
624
|
+
if (path2) {
|
625
|
+
free(path2);
|
626
|
+
}
|
627
|
+
}
|
628
|
+
|
629
|
+
return 0;
|
630
|
+
}
|
631
|
+
|
632
|
+
|
633
|
+
int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
634
|
+
if (cb) {
|
635
|
+
uv_fs_req_init_async(loop, req, UV_FS_FSTAT, cb);
|
636
|
+
WRAP_REQ_ARGS1(req, file);
|
637
|
+
QUEUE_FS_TP_JOB(loop, req);
|
638
|
+
} else {
|
639
|
+
uv_fs_req_init_sync(loop, req, UV_FS_FSTAT);
|
640
|
+
fs__fstat(req, file);
|
641
|
+
}
|
642
|
+
|
643
|
+
return 0;
|
644
|
+
}
|
645
|
+
|
646
|
+
|
647
|
+
int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
648
|
+
const char* new_path, uv_fs_cb cb) {
|
649
|
+
if (cb) {
|
650
|
+
uv_fs_req_init_async(loop, req, UV_FS_RENAME, cb);
|
651
|
+
WRAP_REQ_ARGS2(req, path, new_path);
|
652
|
+
STRDUP_ARG(req, 0);
|
653
|
+
STRDUP_ARG(req, 1);
|
654
|
+
QUEUE_FS_TP_JOB(loop, req);
|
655
|
+
} else {
|
656
|
+
uv_fs_req_init_sync(loop, req, UV_FS_RENAME);
|
657
|
+
fs__rename(req, path, new_path);
|
658
|
+
}
|
659
|
+
|
660
|
+
return 0;
|
661
|
+
}
|
662
|
+
|
663
|
+
|
664
|
+
int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
665
|
+
if (cb) {
|
666
|
+
uv_fs_req_init_async(loop, req, UV_FS_FDATASYNC, cb);
|
667
|
+
WRAP_REQ_ARGS1(req, file);
|
668
|
+
QUEUE_FS_TP_JOB(loop, req);
|
669
|
+
} else {
|
670
|
+
uv_fs_req_init_sync(loop, req, UV_FS_FDATASYNC);
|
671
|
+
fs__fsync(req, file);
|
672
|
+
}
|
673
|
+
|
674
|
+
return 0;
|
675
|
+
}
|
676
|
+
|
677
|
+
|
678
|
+
int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
679
|
+
if (cb) {
|
680
|
+
uv_fs_req_init_async(loop, req, UV_FS_FSYNC, cb);
|
681
|
+
WRAP_REQ_ARGS1(req, file);
|
682
|
+
QUEUE_FS_TP_JOB(loop, req);
|
683
|
+
} else {
|
684
|
+
uv_fs_req_init_sync(loop, req, UV_FS_FSYNC);
|
685
|
+
fs__fsync(req, file);
|
686
|
+
}
|
687
|
+
|
688
|
+
return 0;
|
689
|
+
}
|
690
|
+
|
691
|
+
|
692
|
+
int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file,
|
693
|
+
off_t offset, uv_fs_cb cb) {
|
694
|
+
if (cb) {
|
695
|
+
uv_fs_req_init_async(loop, req, UV_FS_FTRUNCATE, cb);
|
696
|
+
WRAP_REQ_ARGS2(req, file, offset);
|
697
|
+
QUEUE_FS_TP_JOB(loop, req);
|
698
|
+
} else {
|
699
|
+
uv_fs_req_init_sync(loop, req, UV_FS_FTRUNCATE);
|
700
|
+
fs__ftruncate(req, file, offset);
|
701
|
+
}
|
702
|
+
|
703
|
+
return 0;
|
704
|
+
}
|
705
|
+
|
706
|
+
|
707
|
+
int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd,
|
708
|
+
uv_file in_fd, off_t in_offset, size_t length, uv_fs_cb cb) {
|
709
|
+
if (cb) {
|
710
|
+
uv_fs_req_init_async(loop, req, UV_FS_SENDFILE, cb);
|
711
|
+
WRAP_REQ_ARGS4(req, out_fd, in_fd, in_offset, length);
|
712
|
+
QUEUE_FS_TP_JOB(loop, req);
|
713
|
+
} else {
|
714
|
+
uv_fs_req_init_sync(loop, req, UV_FS_SENDFILE);
|
715
|
+
fs__sendfile(req, out_fd, in_fd, in_offset, length);
|
716
|
+
}
|
717
|
+
|
718
|
+
return 0;
|
719
|
+
}
|
720
|
+
|
721
|
+
|
722
|
+
int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode,
|
723
|
+
uv_fs_cb cb) {
|
724
|
+
if (cb) {
|
725
|
+
uv_fs_req_init_async(loop, req, UV_FS_CHMOD, cb);
|
726
|
+
WRAP_REQ_ARGS2(req, path, mode);
|
727
|
+
STRDUP_ARG(req, 0);
|
728
|
+
QUEUE_FS_TP_JOB(loop, req);
|
729
|
+
} else {
|
730
|
+
uv_fs_req_init_sync(loop, req, UV_FS_CHMOD);
|
731
|
+
fs__chmod(req, path, mode);
|
732
|
+
}
|
733
|
+
|
734
|
+
return 0;
|
735
|
+
}
|
736
|
+
|
737
|
+
|
738
|
+
int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime,
|
739
|
+
double mtime, uv_fs_cb cb) {
|
740
|
+
if (cb) {
|
741
|
+
uv_fs_req_init_async(loop, req, UV_FS_UTIME, cb);
|
742
|
+
WRAP_REQ_ARGS1(req, path);
|
743
|
+
STRDUP_ARG(req, 0);
|
744
|
+
req->arg4 = (ssize_t)atime;
|
745
|
+
req->arg5 = (ssize_t)mtime;
|
746
|
+
QUEUE_FS_TP_JOB(loop, req);
|
747
|
+
} else {
|
748
|
+
uv_fs_req_init_sync(loop, req, UV_FS_UTIME);
|
749
|
+
fs__utime(req, path, atime, mtime);
|
750
|
+
}
|
751
|
+
|
752
|
+
return 0;
|
753
|
+
}
|
754
|
+
|
755
|
+
|
756
|
+
int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime,
|
757
|
+
double mtime, uv_fs_cb cb) {
|
758
|
+
if (cb) {
|
759
|
+
uv_fs_req_init_async(loop, req, UV_FS_FUTIME, cb);
|
760
|
+
WRAP_REQ_ARGS1(req, file);
|
761
|
+
req->arg4 = (ssize_t)atime;
|
762
|
+
req->arg5 = (ssize_t)mtime;
|
763
|
+
QUEUE_FS_TP_JOB(loop, req);
|
764
|
+
} else {
|
765
|
+
uv_fs_req_init_sync(loop, req, UV_FS_FUTIME);
|
766
|
+
fs__futime(req, file, atime, mtime);
|
767
|
+
}
|
768
|
+
|
769
|
+
return 0;
|
770
|
+
}
|
771
|
+
|
772
|
+
|
773
|
+
void uv_process_fs_req(uv_loop_t* loop, uv_fs_t* req) {
|
774
|
+
assert(req->cb);
|
775
|
+
req->cb(req);
|
776
|
+
}
|
777
|
+
|
778
|
+
|
779
|
+
void uv_fs_req_cleanup(uv_fs_t* req) {
|
780
|
+
uv_loop_t* loop = req->loop;
|
781
|
+
|
782
|
+
if (req->flags & UV_FS_CLEANEDUP) {
|
783
|
+
return;
|
784
|
+
}
|
785
|
+
|
786
|
+
if (req->flags & UV_FS_FREE_ARG0 && req->arg0) {
|
787
|
+
free(req->arg0);
|
788
|
+
req->arg0 = NULL;
|
789
|
+
}
|
790
|
+
|
791
|
+
if (req->flags & UV_FS_FREE_ARG1 && req->arg1) {
|
792
|
+
free(req->arg1);
|
793
|
+
req->arg1 = NULL;
|
794
|
+
}
|
795
|
+
|
796
|
+
if (req->flags & UV_FS_FREE_PTR && req->ptr) {
|
797
|
+
free(req->ptr);
|
798
|
+
}
|
799
|
+
|
800
|
+
req->ptr = NULL;
|
801
|
+
|
802
|
+
if (req->flags & UV_FS_ASYNC_QUEUED) {
|
803
|
+
uv_unref(loop);
|
804
|
+
}
|
805
|
+
|
806
|
+
req->flags |= UV_FS_CLEANEDUP;
|
807
|
+
}
|