asyncengine 0.0.1.testing
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +0 -0
- data/asyncengine.gemspec +26 -0
- data/ext/asyncengine_ext/asyncengine_ruby.c +82 -0
- data/ext/asyncengine_ext/extconf.rb +47 -0
- data/ext/asyncengine_ext/libuv/AUTHORS +45 -0
- data/ext/asyncengine_ext/libuv/LICENSE +42 -0
- data/ext/asyncengine_ext/libuv/Makefile +119 -0
- data/ext/asyncengine_ext/libuv/README.md +88 -0
- data/ext/asyncengine_ext/libuv/build/gcc_version.py +20 -0
- data/ext/asyncengine_ext/libuv/common.gypi +176 -0
- data/ext/asyncengine_ext/libuv/config-mingw.mk +61 -0
- data/ext/asyncengine_ext/libuv/config-unix.mk +173 -0
- data/ext/asyncengine_ext/libuv/gyp_uv +60 -0
- data/ext/asyncengine_ext/libuv/include/ares.h +591 -0
- data/ext/asyncengine_ext/libuv/include/ares_version.h +24 -0
- data/ext/asyncengine_ext/libuv/include/uv-private/eio.h +403 -0
- data/ext/asyncengine_ext/libuv/include/uv-private/ev.h +838 -0
- data/ext/asyncengine_ext/libuv/include/uv-private/ngx-queue.h +106 -0
- data/ext/asyncengine_ext/libuv/include/uv-private/tree.h +768 -0
- data/ext/asyncengine_ext/libuv/include/uv-private/uv-unix.h +256 -0
- data/ext/asyncengine_ext/libuv/include/uv-private/uv-win.h +458 -0
- data/ext/asyncengine_ext/libuv/include/uv.h +1556 -0
- data/ext/asyncengine_ext/libuv/src/ares/AUTHORS +37 -0
- data/ext/asyncengine_ext/libuv/src/ares/CHANGES +1218 -0
- data/ext/asyncengine_ext/libuv/src/ares/CMakeLists.txt +22 -0
- data/ext/asyncengine_ext/libuv/src/ares/NEWS +21 -0
- data/ext/asyncengine_ext/libuv/src/ares/README +60 -0
- data/ext/asyncengine_ext/libuv/src/ares/README.cares +13 -0
- data/ext/asyncengine_ext/libuv/src/ares/README.msvc +142 -0
- data/ext/asyncengine_ext/libuv/src/ares/README.node +21 -0
- data/ext/asyncengine_ext/libuv/src/ares/RELEASE-NOTES +26 -0
- data/ext/asyncengine_ext/libuv/src/ares/TODO +23 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares__close_sockets.c +66 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares__get_hostent.c +263 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares__read_line.c +71 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares__timeval.c +111 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_cancel.c +63 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_data.c +190 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_data.h +65 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_destroy.c +105 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_dns.h +90 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_expand_name.c +200 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_expand_string.c +75 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_fds.c +63 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_free_hostent.c +42 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_free_string.c +25 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_getenv.c +30 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_getenv.h +26 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_gethostbyaddr.c +301 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_gethostbyname.c +523 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_getnameinfo.c +427 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_getopt.c +122 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_getopt.h +53 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_getsock.c +72 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_init.c +1809 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_iphlpapi.h +221 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_ipv6.h +78 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_library_init.c +142 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_library_init.h +42 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_llist.c +86 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_llist.h +42 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_mkquery.c +195 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_nowarn.c +181 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_nowarn.h +55 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_options.c +248 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_a_reply.c +263 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_aaaa_reply.c +259 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_mx_reply.c +170 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_ns_reply.c +182 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_ptr_reply.c +217 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_srv_reply.c +179 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_txt_reply.c +201 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_platform.c +11035 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_platform.h +43 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_private.h +355 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_process.c +1295 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_query.c +183 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_rules.h +144 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_search.c +321 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_send.c +134 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_setup.h +199 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_strcasecmp.c +66 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_strcasecmp.h +30 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_strdup.c +42 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_strdup.h +26 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_strerror.c +56 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_timeout.c +80 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_version.c +11 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_writev.c +79 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_writev.h +36 -0
- data/ext/asyncengine_ext/libuv/src/ares/bitncmp.c +59 -0
- data/ext/asyncengine_ext/libuv/src/ares/bitncmp.h +26 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_cygwin/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_darwin/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_freebsd/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_linux/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_netbsd/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_openbsd/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_sunos/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_win32/ares_config.h +369 -0
- data/ext/asyncengine_ext/libuv/src/ares/get_ver.awk +35 -0
- data/ext/asyncengine_ext/libuv/src/ares/inet_net_pton.c +451 -0
- data/ext/asyncengine_ext/libuv/src/ares/inet_net_pton.h +31 -0
- data/ext/asyncengine_ext/libuv/src/ares/inet_ntop.c +208 -0
- data/ext/asyncengine_ext/libuv/src/ares/inet_ntop.h +26 -0
- data/ext/asyncengine_ext/libuv/src/ares/nameser.h +203 -0
- data/ext/asyncengine_ext/libuv/src/ares/setup_once.h +504 -0
- data/ext/asyncengine_ext/libuv/src/ares/windows_port.c +22 -0
- data/ext/asyncengine_ext/libuv/src/unix/async.c +58 -0
- data/ext/asyncengine_ext/libuv/src/unix/cares.c +194 -0
- data/ext/asyncengine_ext/libuv/src/unix/check.c +80 -0
- data/ext/asyncengine_ext/libuv/src/unix/core.c +588 -0
- data/ext/asyncengine_ext/libuv/src/unix/cygwin.c +84 -0
- data/ext/asyncengine_ext/libuv/src/unix/darwin.c +341 -0
- data/ext/asyncengine_ext/libuv/src/unix/dl.c +91 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/Changes +63 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/LICENSE +36 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/Makefile.am +15 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/aclocal.m4 +8957 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/autogen.sh +3 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config.h.in +86 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_cygwin.h +80 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_darwin.h +141 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_freebsd.h +81 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_linux.h +94 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_netbsd.h +81 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_openbsd.h +137 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_sunos.h +84 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/configure.ac +22 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/demo.c +194 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/ecb.h +370 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/eio.3 +3428 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/eio.c +2593 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/eio.pod +969 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/libeio.m4 +195 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/xthread.h +164 -0
- data/ext/asyncengine_ext/libuv/src/unix/error.c +98 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/Changes +388 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/LICENSE +36 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/Makefile.am +18 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/Makefile.in +771 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/README +58 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/aclocal.m4 +8957 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/autogen.sh +6 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config.guess +1526 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config.h.in +125 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config.sub +1658 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_cygwin.h +123 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_darwin.h +122 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_freebsd.h +120 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_linux.h +141 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_netbsd.h +120 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_openbsd.h +126 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_sunos.h +122 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/configure +13037 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/configure.ac +18 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/depcomp +630 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev++.h +816 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev.3 +5311 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev.c +3921 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev.pod +5243 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_epoll.c +266 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_kqueue.c +235 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_poll.c +148 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_port.c +179 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_select.c +310 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_vars.h +203 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_win32.c +153 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_wrap.h +196 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/event.c +402 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/event.h +170 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/install-sh +294 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/libev.m4 +39 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ltmain.sh +8413 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/missing +336 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/mkinstalldirs +111 -0
- data/ext/asyncengine_ext/libuv/src/unix/freebsd.c +312 -0
- data/ext/asyncengine_ext/libuv/src/unix/fs.c +707 -0
- data/ext/asyncengine_ext/libuv/src/unix/idle.c +79 -0
- data/ext/asyncengine_ext/libuv/src/unix/internal.h +161 -0
- data/ext/asyncengine_ext/libuv/src/unix/kqueue.c +127 -0
- data/ext/asyncengine_ext/libuv/src/unix/linux/core.c +474 -0
- data/ext/asyncengine_ext/libuv/src/unix/linux/inotify.c +211 -0
- data/ext/asyncengine_ext/libuv/src/unix/linux/syscalls.c +230 -0
- data/ext/asyncengine_ext/libuv/src/unix/linux/syscalls.h +87 -0
- data/ext/asyncengine_ext/libuv/src/unix/loop.c +58 -0
- data/ext/asyncengine_ext/libuv/src/unix/netbsd.c +108 -0
- data/ext/asyncengine_ext/libuv/src/unix/openbsd.c +295 -0
- data/ext/asyncengine_ext/libuv/src/unix/pipe.c +266 -0
- data/ext/asyncengine_ext/libuv/src/unix/prepare.c +79 -0
- data/ext/asyncengine_ext/libuv/src/unix/process.c +369 -0
- data/ext/asyncengine_ext/libuv/src/unix/stream.c +1033 -0
- data/ext/asyncengine_ext/libuv/src/unix/sunos.c +466 -0
- data/ext/asyncengine_ext/libuv/src/unix/tcp.c +327 -0
- data/ext/asyncengine_ext/libuv/src/unix/thread.c +154 -0
- data/ext/asyncengine_ext/libuv/src/unix/timer.c +127 -0
- data/ext/asyncengine_ext/libuv/src/unix/tty.c +146 -0
- data/ext/asyncengine_ext/libuv/src/unix/udp.c +670 -0
- data/ext/asyncengine_ext/libuv/src/unix/uv-eio.c +124 -0
- data/ext/asyncengine_ext/libuv/src/unix/uv-eio.h +13 -0
- data/ext/asyncengine_ext/libuv/src/uv-common.c +354 -0
- data/ext/asyncengine_ext/libuv/src/uv-common.h +87 -0
- data/ext/asyncengine_ext/libuv/src/win/async.c +127 -0
- data/ext/asyncengine_ext/libuv/src/win/cares.c +290 -0
- data/ext/asyncengine_ext/libuv/src/win/core.c +270 -0
- data/ext/asyncengine_ext/libuv/src/win/dl.c +82 -0
- data/ext/asyncengine_ext/libuv/src/win/error.c +132 -0
- data/ext/asyncengine_ext/libuv/src/win/fs-event.c +514 -0
- data/ext/asyncengine_ext/libuv/src/win/fs.c +1576 -0
- data/ext/asyncengine_ext/libuv/src/win/getaddrinfo.c +372 -0
- data/ext/asyncengine_ext/libuv/src/win/handle.c +225 -0
- data/ext/asyncengine_ext/libuv/src/win/internal.h +352 -0
- data/ext/asyncengine_ext/libuv/src/win/loop-watcher.c +131 -0
- data/ext/asyncengine_ext/libuv/src/win/pipe.c +1661 -0
- data/ext/asyncengine_ext/libuv/src/win/process.c +1140 -0
- data/ext/asyncengine_ext/libuv/src/win/req.c +174 -0
- data/ext/asyncengine_ext/libuv/src/win/stream.c +201 -0
- data/ext/asyncengine_ext/libuv/src/win/tcp.c +1282 -0
- data/ext/asyncengine_ext/libuv/src/win/thread.c +332 -0
- data/ext/asyncengine_ext/libuv/src/win/threadpool.c +73 -0
- data/ext/asyncengine_ext/libuv/src/win/timer.c +276 -0
- data/ext/asyncengine_ext/libuv/src/win/tty.c +1795 -0
- data/ext/asyncengine_ext/libuv/src/win/udp.c +709 -0
- data/ext/asyncengine_ext/libuv/src/win/util.c +719 -0
- data/ext/asyncengine_ext/libuv/src/win/winapi.c +117 -0
- data/ext/asyncengine_ext/libuv/src/win/winapi.h +4419 -0
- data/ext/asyncengine_ext/libuv/src/win/winsock.c +470 -0
- data/ext/asyncengine_ext/libuv/src/win/winsock.h +138 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-ares.c +118 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-getaddrinfo.c +94 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-list.h +105 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-ping-pongs.c +213 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-pound.c +324 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-pump.c +462 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-sizes.c +40 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-spawn.c +156 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-tcp-write-batch.c +140 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-thread.c +64 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-udp-packet-storm.c +247 -0
- data/ext/asyncengine_ext/libuv/test/blackhole-server.c +118 -0
- data/ext/asyncengine_ext/libuv/test/dns-server.c +321 -0
- data/ext/asyncengine_ext/libuv/test/echo-server.c +370 -0
- data/ext/asyncengine_ext/libuv/test/fixtures/empty_file +0 -0
- data/ext/asyncengine_ext/libuv/test/fixtures/load_error.node +1 -0
- data/ext/asyncengine_ext/libuv/test/run-benchmarks.c +64 -0
- data/ext/asyncengine_ext/libuv/test/run-tests.c +108 -0
- data/ext/asyncengine_ext/libuv/test/runner-unix.c +315 -0
- data/ext/asyncengine_ext/libuv/test/runner-unix.h +36 -0
- data/ext/asyncengine_ext/libuv/test/runner-win.c +343 -0
- data/ext/asyncengine_ext/libuv/test/runner-win.h +42 -0
- data/ext/asyncengine_ext/libuv/test/runner.c +317 -0
- data/ext/asyncengine_ext/libuv/test/runner.h +159 -0
- data/ext/asyncengine_ext/libuv/test/task.h +117 -0
- data/ext/asyncengine_ext/libuv/test/test-async.c +216 -0
- data/ext/asyncengine_ext/libuv/test/test-callback-stack.c +203 -0
- data/ext/asyncengine_ext/libuv/test/test-connection-fail.c +148 -0
- data/ext/asyncengine_ext/libuv/test/test-counters-init.c +216 -0
- data/ext/asyncengine_ext/libuv/test/test-cwd-and-chdir.c +64 -0
- data/ext/asyncengine_ext/libuv/test/test-delayed-accept.c +197 -0
- data/ext/asyncengine_ext/libuv/test/test-dlerror.c +49 -0
- data/ext/asyncengine_ext/libuv/test/test-eio-overflow.c +90 -0
- data/ext/asyncengine_ext/libuv/test/test-error.c +59 -0
- data/ext/asyncengine_ext/libuv/test/test-fail-always.c +29 -0
- data/ext/asyncengine_ext/libuv/test/test-fs-event.c +442 -0
- data/ext/asyncengine_ext/libuv/test/test-fs.c +1731 -0
- data/ext/asyncengine_ext/libuv/test/test-get-currentexe.c +63 -0
- data/ext/asyncengine_ext/libuv/test/test-get-loadavg.c +36 -0
- data/ext/asyncengine_ext/libuv/test/test-get-memory.c +38 -0
- data/ext/asyncengine_ext/libuv/test/test-getaddrinfo.c +122 -0
- data/ext/asyncengine_ext/libuv/test/test-gethostbyname.c +189 -0
- data/ext/asyncengine_ext/libuv/test/test-getsockname.c +342 -0
- data/ext/asyncengine_ext/libuv/test/test-hrtime.c +51 -0
- data/ext/asyncengine_ext/libuv/test/test-idle.c +81 -0
- data/ext/asyncengine_ext/libuv/test/test-ipc-send-recv.c +209 -0
- data/ext/asyncengine_ext/libuv/test/test-ipc.c +614 -0
- data/ext/asyncengine_ext/libuv/test/test-list.h +371 -0
- data/ext/asyncengine_ext/libuv/test/test-loop-handles.c +359 -0
- data/ext/asyncengine_ext/libuv/test/test-multiple-listen.c +102 -0
- data/ext/asyncengine_ext/libuv/test/test-mutexes.c +63 -0
- data/ext/asyncengine_ext/libuv/test/test-pass-always.c +28 -0
- data/ext/asyncengine_ext/libuv/test/test-ping-pong.c +253 -0
- data/ext/asyncengine_ext/libuv/test/test-pipe-bind-error.c +140 -0
- data/ext/asyncengine_ext/libuv/test/test-pipe-connect-error.c +96 -0
- data/ext/asyncengine_ext/libuv/test/test-platform-output.c +87 -0
- data/ext/asyncengine_ext/libuv/test/test-process-title.c +42 -0
- data/ext/asyncengine_ext/libuv/test/test-ref.c +322 -0
- data/ext/asyncengine_ext/libuv/test/test-run-once.c +44 -0
- data/ext/asyncengine_ext/libuv/test/test-shutdown-close.c +103 -0
- data/ext/asyncengine_ext/libuv/test/test-shutdown-eof.c +183 -0
- data/ext/asyncengine_ext/libuv/test/test-spawn.c +499 -0
- data/ext/asyncengine_ext/libuv/test/test-stdio-over-pipes.c +256 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-bind-error.c +191 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-bind6-error.c +154 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-close.c +129 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-connect-error.c +70 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-connect6-error.c +68 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-flags.c +51 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-write-error.c +168 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-write-to-half-open-connection.c +135 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-writealot.c +195 -0
- data/ext/asyncengine_ext/libuv/test/test-thread.c +183 -0
- data/ext/asyncengine_ext/libuv/test/test-threadpool.c +57 -0
- data/ext/asyncengine_ext/libuv/test/test-timer-again.c +141 -0
- data/ext/asyncengine_ext/libuv/test/test-timer.c +130 -0
- data/ext/asyncengine_ext/libuv/test/test-tty.c +110 -0
- data/ext/asyncengine_ext/libuv/test/test-udp-dgram-too-big.c +86 -0
- data/ext/asyncengine_ext/libuv/test/test-udp-ipv6.c +156 -0
- data/ext/asyncengine_ext/libuv/test/test-udp-multicast-join.c +139 -0
- data/ext/asyncengine_ext/libuv/test/test-udp-multicast-ttl.c +86 -0
- data/ext/asyncengine_ext/libuv/test/test-udp-options.c +86 -0
- data/ext/asyncengine_ext/libuv/test/test-udp-send-and-recv.c +208 -0
- data/ext/asyncengine_ext/libuv/test/test-util.c +97 -0
- data/ext/asyncengine_ext/libuv/uv.gyp +435 -0
- data/ext/asyncengine_ext/libuv/vcbuild.bat +105 -0
- data/lib/asyncengine/version.rb +3 -0
- data/lib/asyncengine.rb +41 -0
- metadata +384 -0
@@ -0,0 +1,1576 @@
|
|
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 <errno.h>
|
26
|
+
#include <fcntl.h>
|
27
|
+
#include <io.h>
|
28
|
+
#include <limits.h>
|
29
|
+
#include <sys/stat.h>
|
30
|
+
#include <sys/utime.h>
|
31
|
+
#include <stdio.h>
|
32
|
+
|
33
|
+
#include "uv.h"
|
34
|
+
#include "internal.h"
|
35
|
+
|
36
|
+
#define UV_FS_ASYNC_QUEUED 0x0001
|
37
|
+
#define UV_FS_FREE_ARG0 0x0002
|
38
|
+
#define UV_FS_FREE_ARG1 0x0004
|
39
|
+
#define UV_FS_FREE_PTR 0x0008
|
40
|
+
#define UV_FS_CLEANEDUP 0x0010
|
41
|
+
|
42
|
+
|
43
|
+
#define UTF8_TO_UTF16(s, t) \
|
44
|
+
size = uv_utf8_to_utf16(s, NULL, 0) * sizeof(wchar_t); \
|
45
|
+
t = (wchar_t*)malloc(size); \
|
46
|
+
if (!t) { \
|
47
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); \
|
48
|
+
} \
|
49
|
+
if (!uv_utf8_to_utf16(s, t, size / sizeof(wchar_t))) { \
|
50
|
+
uv__set_sys_error(loop, GetLastError()); \
|
51
|
+
return -1; \
|
52
|
+
}
|
53
|
+
|
54
|
+
#define STRDUP_ARG(req, i) \
|
55
|
+
req->arg##i = (void*)strdup((const char*)req->arg##i); \
|
56
|
+
if (!req->arg##i) { \
|
57
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); \
|
58
|
+
} \
|
59
|
+
req->flags |= UV_FS_FREE_ARG##i;
|
60
|
+
|
61
|
+
#define SET_ALLOCED_ARG(req, i) \
|
62
|
+
req->flags |= UV_FS_FREE_ARG##i;
|
63
|
+
|
64
|
+
#define WRAP_REQ_ARGS1(req, a0) \
|
65
|
+
req->arg0 = (void*)a0;
|
66
|
+
|
67
|
+
#define WRAP_REQ_ARGS2(req, a0, a1) \
|
68
|
+
WRAP_REQ_ARGS1(req, a0) \
|
69
|
+
req->arg1 = (void*)a1;
|
70
|
+
|
71
|
+
#define WRAP_REQ_ARGS3(req, a0, a1, a2) \
|
72
|
+
WRAP_REQ_ARGS2(req, a0, a1) \
|
73
|
+
req->arg2 = (void*)a2;
|
74
|
+
|
75
|
+
#define WRAP_REQ_ARGS4(req, a0, a1, a2, a3) \
|
76
|
+
WRAP_REQ_ARGS3(req, a0, a1, a2) \
|
77
|
+
req->arg3 = (void*)a3;
|
78
|
+
|
79
|
+
#define QUEUE_FS_TP_JOB(loop, req) \
|
80
|
+
if (!QueueUserWorkItem(&uv_fs_thread_proc, \
|
81
|
+
req, \
|
82
|
+
WT_EXECUTELONGFUNCTION)) { \
|
83
|
+
uv__set_sys_error((loop), GetLastError()); \
|
84
|
+
return -1; \
|
85
|
+
} \
|
86
|
+
req->flags |= UV_FS_ASYNC_QUEUED; \
|
87
|
+
uv_ref((loop));
|
88
|
+
|
89
|
+
#define SET_UV_LAST_ERROR_FROM_REQ(req) \
|
90
|
+
uv__set_error(req->loop, req->errorno, req->sys_errno_);
|
91
|
+
|
92
|
+
#define SET_REQ_RESULT(req, result_value) \
|
93
|
+
req->result = (result_value); \
|
94
|
+
if (req->result == -1) { \
|
95
|
+
req->sys_errno_ = _doserrno; \
|
96
|
+
req->errorno = uv_translate_sys_error(req->sys_errno_); \
|
97
|
+
}
|
98
|
+
|
99
|
+
#define SET_REQ_WIN32_ERROR(req, sys_errno) \
|
100
|
+
req->result = -1; \
|
101
|
+
req->sys_errno_ = (sys_errno); \
|
102
|
+
req->errorno = uv_translate_sys_error(req->sys_errno_);
|
103
|
+
|
104
|
+
#define SET_REQ_UV_ERROR(req, uv_errno, sys_errno) \
|
105
|
+
req->result = -1; \
|
106
|
+
req->sys_errno_ = (sys_errno); \
|
107
|
+
req->errorno = (uv_errno);
|
108
|
+
|
109
|
+
#define VERIFY_UV_FILE(file, req) \
|
110
|
+
if (file == -1) { \
|
111
|
+
req->result = -1; \
|
112
|
+
req->errorno = UV_EBADF; \
|
113
|
+
req->sys_errno_ = ERROR_SUCCESS; \
|
114
|
+
return; \
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
void uv_fs_init() {
|
119
|
+
_fmode = _O_BINARY;
|
120
|
+
}
|
121
|
+
|
122
|
+
|
123
|
+
static void uv_fs_req_init_async(uv_loop_t* loop, uv_fs_t* req,
|
124
|
+
uv_fs_type fs_type, const char* path, const wchar_t* pathw, uv_fs_cb cb) {
|
125
|
+
uv_req_init(loop, (uv_req_t*) req);
|
126
|
+
req->type = UV_FS;
|
127
|
+
req->loop = loop;
|
128
|
+
req->flags = 0;
|
129
|
+
req->fs_type = fs_type;
|
130
|
+
req->cb = cb;
|
131
|
+
req->result = 0;
|
132
|
+
req->ptr = NULL;
|
133
|
+
req->path = path ? strdup(path) : NULL;
|
134
|
+
req->pathw = (wchar_t*)pathw;
|
135
|
+
req->errorno = 0;
|
136
|
+
req->sys_errno_ = 0;
|
137
|
+
memset(&req->overlapped, 0, sizeof(req->overlapped));
|
138
|
+
}
|
139
|
+
|
140
|
+
|
141
|
+
static void uv_fs_req_init_sync(uv_loop_t* loop, uv_fs_t* req,
|
142
|
+
uv_fs_type fs_type) {
|
143
|
+
uv_req_init(loop, (uv_req_t*) req);
|
144
|
+
req->type = UV_FS;
|
145
|
+
req->loop = loop;
|
146
|
+
req->flags = 0;
|
147
|
+
req->fs_type = fs_type;
|
148
|
+
req->result = 0;
|
149
|
+
req->ptr = NULL;
|
150
|
+
req->path = NULL;
|
151
|
+
req->pathw = NULL;
|
152
|
+
req->errorno = 0;
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
void fs__open(uv_fs_t* req, const wchar_t* path, int flags, int mode) {
|
157
|
+
DWORD access;
|
158
|
+
DWORD share;
|
159
|
+
DWORD disposition;
|
160
|
+
DWORD attributes;
|
161
|
+
HANDLE file;
|
162
|
+
int result, current_umask;
|
163
|
+
|
164
|
+
/* Obtain the active umask. umask() never fails and returns the previous */
|
165
|
+
/* umask. */
|
166
|
+
current_umask = umask(0);
|
167
|
+
umask(current_umask);
|
168
|
+
|
169
|
+
/* convert flags and mode to CreateFile parameters */
|
170
|
+
switch (flags & (_O_RDONLY | _O_WRONLY | _O_RDWR)) {
|
171
|
+
case _O_RDONLY:
|
172
|
+
access = FILE_GENERIC_READ;
|
173
|
+
break;
|
174
|
+
case _O_WRONLY:
|
175
|
+
access = FILE_GENERIC_WRITE;
|
176
|
+
break;
|
177
|
+
case _O_RDWR:
|
178
|
+
access = FILE_GENERIC_READ | FILE_GENERIC_WRITE;
|
179
|
+
break;
|
180
|
+
default:
|
181
|
+
result = -1;
|
182
|
+
goto end;
|
183
|
+
}
|
184
|
+
|
185
|
+
if (flags & _O_APPEND) {
|
186
|
+
access &= ~FILE_WRITE_DATA;
|
187
|
+
access |= FILE_APPEND_DATA;
|
188
|
+
}
|
189
|
+
|
190
|
+
/*
|
191
|
+
* Here is where we deviate significantly from what CRT's _open()
|
192
|
+
* does. We indiscriminately use all the sharing modes, to match
|
193
|
+
* UNIX semantics. In particular, this ensures that the file can
|
194
|
+
* be deleted even whilst it's open, fixing issue #1449.
|
195
|
+
*/
|
196
|
+
share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
|
197
|
+
|
198
|
+
switch (flags & (_O_CREAT | _O_EXCL | _O_TRUNC)) {
|
199
|
+
case 0:
|
200
|
+
case _O_EXCL:
|
201
|
+
disposition = OPEN_EXISTING;
|
202
|
+
break;
|
203
|
+
case _O_CREAT:
|
204
|
+
disposition = OPEN_ALWAYS;
|
205
|
+
break;
|
206
|
+
case _O_CREAT | _O_EXCL:
|
207
|
+
case _O_CREAT | _O_TRUNC | _O_EXCL:
|
208
|
+
disposition = CREATE_NEW;
|
209
|
+
break;
|
210
|
+
case _O_TRUNC:
|
211
|
+
case _O_TRUNC | _O_EXCL:
|
212
|
+
disposition = TRUNCATE_EXISTING;
|
213
|
+
break;
|
214
|
+
case _O_CREAT | _O_TRUNC:
|
215
|
+
disposition = CREATE_ALWAYS;
|
216
|
+
break;
|
217
|
+
default:
|
218
|
+
result = -1;
|
219
|
+
goto end;
|
220
|
+
}
|
221
|
+
|
222
|
+
attributes = FILE_ATTRIBUTE_NORMAL;
|
223
|
+
if (flags & _O_CREAT) {
|
224
|
+
if (!((mode & ~current_umask) & _S_IWRITE)) {
|
225
|
+
attributes |= FILE_ATTRIBUTE_READONLY;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
if (flags & _O_TEMPORARY ) {
|
230
|
+
attributes |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY;
|
231
|
+
access |= DELETE;
|
232
|
+
}
|
233
|
+
|
234
|
+
if (flags & _O_SHORT_LIVED) {
|
235
|
+
attributes |= FILE_ATTRIBUTE_TEMPORARY;
|
236
|
+
}
|
237
|
+
|
238
|
+
switch (flags & (_O_SEQUENTIAL | _O_RANDOM)) {
|
239
|
+
case 0:
|
240
|
+
break;
|
241
|
+
case _O_SEQUENTIAL:
|
242
|
+
attributes |= FILE_FLAG_SEQUENTIAL_SCAN;
|
243
|
+
break;
|
244
|
+
case _O_RANDOM:
|
245
|
+
attributes |= FILE_FLAG_RANDOM_ACCESS;
|
246
|
+
break;
|
247
|
+
default:
|
248
|
+
result = -1;
|
249
|
+
goto end;
|
250
|
+
}
|
251
|
+
|
252
|
+
/* Figure out whether path is a file or a directory. */
|
253
|
+
if (GetFileAttributesW(path) & FILE_ATTRIBUTE_DIRECTORY) {
|
254
|
+
attributes |= FILE_FLAG_BACKUP_SEMANTICS;
|
255
|
+
}
|
256
|
+
|
257
|
+
file = CreateFileW(path,
|
258
|
+
access,
|
259
|
+
share,
|
260
|
+
NULL,
|
261
|
+
disposition,
|
262
|
+
attributes,
|
263
|
+
NULL);
|
264
|
+
if (file == INVALID_HANDLE_VALUE) {
|
265
|
+
DWORD error = GetLastError();
|
266
|
+
if (error == ERROR_FILE_EXISTS && (flags & _O_CREAT) &&
|
267
|
+
!(flags & _O_EXCL)) {
|
268
|
+
/* Special case: when ERROR_FILE_EXISTS happens and O_CREAT was */
|
269
|
+
/* specified, it means the path referred to a directory. */
|
270
|
+
SET_REQ_UV_ERROR(req, UV_EISDIR, error);
|
271
|
+
} else {
|
272
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
273
|
+
}
|
274
|
+
return;
|
275
|
+
}
|
276
|
+
result = _open_osfhandle((intptr_t)file, flags);
|
277
|
+
end:
|
278
|
+
SET_REQ_RESULT(req, result);
|
279
|
+
}
|
280
|
+
|
281
|
+
void fs__close(uv_fs_t* req, uv_file file) {
|
282
|
+
int result;
|
283
|
+
|
284
|
+
VERIFY_UV_FILE(file, req);
|
285
|
+
|
286
|
+
result = _close(file);
|
287
|
+
SET_REQ_RESULT(req, result);
|
288
|
+
}
|
289
|
+
|
290
|
+
|
291
|
+
void fs__read(uv_fs_t* req, uv_file file, void *buf, size_t length,
|
292
|
+
off_t offset) {
|
293
|
+
HANDLE handle;
|
294
|
+
OVERLAPPED overlapped, *overlapped_ptr;
|
295
|
+
LARGE_INTEGER offset_;
|
296
|
+
DWORD bytes;
|
297
|
+
DWORD error;
|
298
|
+
|
299
|
+
VERIFY_UV_FILE(file, req);
|
300
|
+
|
301
|
+
handle = (HANDLE) _get_osfhandle(file);
|
302
|
+
if (handle == INVALID_HANDLE_VALUE) {
|
303
|
+
SET_REQ_RESULT(req, -1);
|
304
|
+
return;
|
305
|
+
}
|
306
|
+
|
307
|
+
if (length > INT_MAX) {
|
308
|
+
SET_REQ_WIN32_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
|
309
|
+
return;
|
310
|
+
}
|
311
|
+
|
312
|
+
if (offset != -1) {
|
313
|
+
memset(&overlapped, 0, sizeof overlapped);
|
314
|
+
|
315
|
+
offset_.QuadPart = offset;
|
316
|
+
overlapped.Offset = offset_.LowPart;
|
317
|
+
overlapped.OffsetHigh = offset_.HighPart;
|
318
|
+
|
319
|
+
overlapped_ptr = &overlapped;
|
320
|
+
} else {
|
321
|
+
overlapped_ptr = NULL;
|
322
|
+
}
|
323
|
+
|
324
|
+
if (ReadFile(handle, buf, length, &bytes, overlapped_ptr)) {
|
325
|
+
SET_REQ_RESULT(req, bytes);
|
326
|
+
} else {
|
327
|
+
error = GetLastError();
|
328
|
+
if (error == ERROR_HANDLE_EOF) {
|
329
|
+
SET_REQ_RESULT(req, bytes);
|
330
|
+
} else {
|
331
|
+
SET_REQ_WIN32_ERROR(req, error);
|
332
|
+
}
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
|
337
|
+
void fs__write(uv_fs_t* req, uv_file file, void *buf, size_t length,
|
338
|
+
off_t offset) {
|
339
|
+
HANDLE handle;
|
340
|
+
OVERLAPPED overlapped, *overlapped_ptr;
|
341
|
+
LARGE_INTEGER offset_;
|
342
|
+
DWORD bytes;
|
343
|
+
|
344
|
+
VERIFY_UV_FILE(file, req);
|
345
|
+
|
346
|
+
handle = (HANDLE) _get_osfhandle(file);
|
347
|
+
if (handle == INVALID_HANDLE_VALUE) {
|
348
|
+
SET_REQ_RESULT(req, -1);
|
349
|
+
return;
|
350
|
+
}
|
351
|
+
|
352
|
+
if (length > INT_MAX) {
|
353
|
+
SET_REQ_WIN32_ERROR(req, ERROR_INSUFFICIENT_BUFFER);
|
354
|
+
return;
|
355
|
+
}
|
356
|
+
|
357
|
+
if (offset != -1) {
|
358
|
+
memset(&overlapped, 0, sizeof overlapped);
|
359
|
+
|
360
|
+
offset_.QuadPart = offset;
|
361
|
+
overlapped.Offset = offset_.LowPart;
|
362
|
+
overlapped.OffsetHigh = offset_.HighPart;
|
363
|
+
|
364
|
+
overlapped_ptr = &overlapped;
|
365
|
+
} else {
|
366
|
+
overlapped_ptr = NULL;
|
367
|
+
}
|
368
|
+
|
369
|
+
if (WriteFile(handle, buf, length, &bytes, overlapped_ptr)) {
|
370
|
+
SET_REQ_RESULT(req, bytes);
|
371
|
+
} else {
|
372
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
|
377
|
+
void fs__unlink(uv_fs_t* req, const wchar_t* path) {
|
378
|
+
int result = _wunlink(path);
|
379
|
+
SET_REQ_RESULT(req, result);
|
380
|
+
}
|
381
|
+
|
382
|
+
|
383
|
+
void fs__mkdir(uv_fs_t* req, const wchar_t* path, int mode) {
|
384
|
+
int result = _wmkdir(path);
|
385
|
+
SET_REQ_RESULT(req, result);
|
386
|
+
}
|
387
|
+
|
388
|
+
|
389
|
+
void fs__rmdir(uv_fs_t* req, const wchar_t* path) {
|
390
|
+
int result = _wrmdir(path);
|
391
|
+
SET_REQ_RESULT(req, result);
|
392
|
+
}
|
393
|
+
|
394
|
+
|
395
|
+
void fs__readdir(uv_fs_t* req, const wchar_t* path, int flags) {
|
396
|
+
int result, size;
|
397
|
+
wchar_t* buf = NULL, *ptr, *name;
|
398
|
+
HANDLE dir;
|
399
|
+
WIN32_FIND_DATAW ent = {0};
|
400
|
+
size_t len = wcslen(path);
|
401
|
+
size_t buf_char_len = 4096;
|
402
|
+
wchar_t* path2;
|
403
|
+
const wchar_t* fmt = !len ? L"./*"
|
404
|
+
: (path[len - 1] == L'/' || path[len - 1] == L'\\') ? L"%s*"
|
405
|
+
: L"%s\\*";
|
406
|
+
|
407
|
+
/* Figure out whether path is a file or a directory. */
|
408
|
+
if (!(GetFileAttributesW(path) & FILE_ATTRIBUTE_DIRECTORY)) {
|
409
|
+
req->result = -1;
|
410
|
+
req->errorno = UV_ENOTDIR;
|
411
|
+
req->sys_errno_ = ERROR_SUCCESS;
|
412
|
+
return;
|
413
|
+
}
|
414
|
+
|
415
|
+
path2 = (wchar_t*)malloc(sizeof(wchar_t) * (len + 4));
|
416
|
+
if (!path2) {
|
417
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
418
|
+
}
|
419
|
+
|
420
|
+
#ifdef _MSC_VER
|
421
|
+
swprintf(path2, len + 3, fmt, path);
|
422
|
+
#else
|
423
|
+
swprintf(path2, fmt, path);
|
424
|
+
#endif
|
425
|
+
dir = FindFirstFileW(path2, &ent);
|
426
|
+
free(path2);
|
427
|
+
|
428
|
+
if(dir == INVALID_HANDLE_VALUE) {
|
429
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
430
|
+
return;
|
431
|
+
}
|
432
|
+
|
433
|
+
result = 0;
|
434
|
+
|
435
|
+
do {
|
436
|
+
name = ent.cFileName;
|
437
|
+
|
438
|
+
if (name[0] != L'.' || (name[1] && (name[1] != L'.' || name[2]))) {
|
439
|
+
len = wcslen(name);
|
440
|
+
|
441
|
+
if (!buf) {
|
442
|
+
buf = (wchar_t*)malloc(buf_char_len * sizeof(wchar_t));
|
443
|
+
if (!buf) {
|
444
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
445
|
+
}
|
446
|
+
|
447
|
+
ptr = buf;
|
448
|
+
}
|
449
|
+
|
450
|
+
while ((ptr - buf) + len + 1 > buf_char_len) {
|
451
|
+
buf_char_len *= 2;
|
452
|
+
path2 = buf;
|
453
|
+
buf = (wchar_t*)realloc(buf, buf_char_len * sizeof(wchar_t));
|
454
|
+
if (!buf) {
|
455
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "realloc");
|
456
|
+
}
|
457
|
+
|
458
|
+
ptr = buf + (ptr - path2);
|
459
|
+
}
|
460
|
+
|
461
|
+
wcscpy(ptr, name);
|
462
|
+
ptr += len + 1;
|
463
|
+
result++;
|
464
|
+
}
|
465
|
+
} while(FindNextFileW(dir, &ent));
|
466
|
+
|
467
|
+
FindClose(dir);
|
468
|
+
|
469
|
+
if (buf) {
|
470
|
+
/* Convert result to UTF8. */
|
471
|
+
size = uv_utf16_to_utf8(buf, buf_char_len, NULL, 0);
|
472
|
+
if (!size) {
|
473
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
474
|
+
return;
|
475
|
+
}
|
476
|
+
|
477
|
+
req->ptr = (char*)malloc(size + 1);
|
478
|
+
if (!req->ptr) {
|
479
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
480
|
+
}
|
481
|
+
|
482
|
+
size = uv_utf16_to_utf8(buf, buf_char_len, (char*)req->ptr, size);
|
483
|
+
if (!size) {
|
484
|
+
free(buf);
|
485
|
+
free(req->ptr);
|
486
|
+
req->ptr = NULL;
|
487
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
488
|
+
return;
|
489
|
+
}
|
490
|
+
free(buf);
|
491
|
+
|
492
|
+
((char*)req->ptr)[size] = '\0';
|
493
|
+
req->flags |= UV_FS_FREE_PTR;
|
494
|
+
} else {
|
495
|
+
req->ptr = NULL;
|
496
|
+
}
|
497
|
+
|
498
|
+
SET_REQ_RESULT(req, result);
|
499
|
+
}
|
500
|
+
|
501
|
+
|
502
|
+
static void fs__stat(uv_fs_t* req, const wchar_t* path) {
|
503
|
+
HANDLE handle;
|
504
|
+
BY_HANDLE_FILE_INFORMATION info;
|
505
|
+
|
506
|
+
req->ptr = NULL;
|
507
|
+
|
508
|
+
handle = CreateFileW(path,
|
509
|
+
FILE_READ_ATTRIBUTES,
|
510
|
+
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
511
|
+
NULL,
|
512
|
+
OPEN_EXISTING,
|
513
|
+
FILE_FLAG_BACKUP_SEMANTICS,
|
514
|
+
NULL);
|
515
|
+
if (handle == INVALID_HANDLE_VALUE) {
|
516
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
517
|
+
return;
|
518
|
+
}
|
519
|
+
|
520
|
+
if (!GetFileInformationByHandle(handle, &info)) {
|
521
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
522
|
+
CloseHandle(handle);
|
523
|
+
return;
|
524
|
+
}
|
525
|
+
|
526
|
+
memset(&req->stat, 0, sizeof req->stat);
|
527
|
+
|
528
|
+
/* TODO: set st_dev and st_ino? */
|
529
|
+
|
530
|
+
if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
|
531
|
+
req->stat.st_mode |= (_S_IREAD + (_S_IREAD >> 3) + (_S_IREAD >> 6));
|
532
|
+
} else {
|
533
|
+
req->stat.st_mode |= ((_S_IREAD|_S_IWRITE) + ((_S_IREAD|_S_IWRITE) >> 3) +
|
534
|
+
((_S_IREAD|_S_IWRITE) >> 6));
|
535
|
+
}
|
536
|
+
|
537
|
+
if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
538
|
+
req->stat.st_mode |= _S_IFDIR;
|
539
|
+
} else {
|
540
|
+
req->stat.st_mode |= _S_IFREG;
|
541
|
+
}
|
542
|
+
|
543
|
+
uv_filetime_to_time_t(&info.ftLastWriteTime, &(req->stat.st_mtime));
|
544
|
+
uv_filetime_to_time_t(&info.ftLastAccessTime, &(req->stat.st_atime));
|
545
|
+
uv_filetime_to_time_t(&info.ftCreationTime, &(req->stat.st_ctime));
|
546
|
+
|
547
|
+
req->stat.st_size = ((int64_t) info.nFileSizeHigh << 32) +
|
548
|
+
(int64_t) info.nFileSizeLow;
|
549
|
+
|
550
|
+
req->stat.st_nlink = (info.nNumberOfLinks <= SHRT_MAX) ?
|
551
|
+
(short) info.nNumberOfLinks : SHRT_MAX;
|
552
|
+
|
553
|
+
req->ptr = &req->stat;
|
554
|
+
req->result = 0;
|
555
|
+
|
556
|
+
CloseHandle(handle);
|
557
|
+
}
|
558
|
+
|
559
|
+
|
560
|
+
void fs__fstat(uv_fs_t* req, uv_file file) {
|
561
|
+
int result;
|
562
|
+
|
563
|
+
VERIFY_UV_FILE(file, req);
|
564
|
+
|
565
|
+
result = _fstati64(file, &req->stat);
|
566
|
+
if (result == -1) {
|
567
|
+
req->ptr = NULL;
|
568
|
+
} else {
|
569
|
+
req->ptr = &req->stat;
|
570
|
+
}
|
571
|
+
|
572
|
+
SET_REQ_RESULT(req, result);
|
573
|
+
}
|
574
|
+
|
575
|
+
|
576
|
+
void fs__rename(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path) {
|
577
|
+
if (!MoveFileExW(path, new_path, MOVEFILE_REPLACE_EXISTING)) {
|
578
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
579
|
+
return;
|
580
|
+
}
|
581
|
+
|
582
|
+
SET_REQ_RESULT(req, 0);
|
583
|
+
}
|
584
|
+
|
585
|
+
|
586
|
+
void fs__fsync(uv_fs_t* req, uv_file file) {
|
587
|
+
int result;
|
588
|
+
|
589
|
+
VERIFY_UV_FILE(file, req);
|
590
|
+
|
591
|
+
result = FlushFileBuffers((HANDLE)_get_osfhandle(file)) ? 0 : -1;
|
592
|
+
if (result == -1) {
|
593
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
594
|
+
} else {
|
595
|
+
SET_REQ_RESULT(req, result);
|
596
|
+
}
|
597
|
+
}
|
598
|
+
|
599
|
+
|
600
|
+
void fs__ftruncate(uv_fs_t* req, uv_file file, off_t offset) {
|
601
|
+
int result;
|
602
|
+
|
603
|
+
VERIFY_UV_FILE(file, req);
|
604
|
+
|
605
|
+
result = _chsize(file, offset);
|
606
|
+
SET_REQ_RESULT(req, result);
|
607
|
+
}
|
608
|
+
|
609
|
+
|
610
|
+
void fs__sendfile(uv_fs_t* req, uv_file out_file, uv_file in_file,
|
611
|
+
off_t in_offset, size_t length) {
|
612
|
+
const size_t max_buf_size = 65536;
|
613
|
+
size_t buf_size = length < max_buf_size ? length : max_buf_size;
|
614
|
+
int n, result = 0;
|
615
|
+
char* buf = (char*)malloc(buf_size);
|
616
|
+
if (!buf) {
|
617
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
618
|
+
}
|
619
|
+
|
620
|
+
if (in_offset != -1) {
|
621
|
+
result = _lseek(in_file, in_offset, SEEK_SET);
|
622
|
+
}
|
623
|
+
|
624
|
+
if (result != -1) {
|
625
|
+
while (length > 0) {
|
626
|
+
n = _read(in_file, buf, length < buf_size ? length : buf_size);
|
627
|
+
if (n == 0) {
|
628
|
+
break;
|
629
|
+
} else if (n == -1) {
|
630
|
+
result = -1;
|
631
|
+
break;
|
632
|
+
}
|
633
|
+
|
634
|
+
length -= n;
|
635
|
+
|
636
|
+
n = _write(out_file, buf, n);
|
637
|
+
if (n == -1) {
|
638
|
+
result = -1;
|
639
|
+
break;
|
640
|
+
}
|
641
|
+
|
642
|
+
result += n;
|
643
|
+
}
|
644
|
+
}
|
645
|
+
|
646
|
+
SET_REQ_RESULT(req, result);
|
647
|
+
}
|
648
|
+
|
649
|
+
|
650
|
+
void fs__chmod(uv_fs_t* req, const wchar_t* path, int mode) {
|
651
|
+
int result = _wchmod(path, mode);
|
652
|
+
SET_REQ_RESULT(req, result);
|
653
|
+
}
|
654
|
+
|
655
|
+
|
656
|
+
void fs__fchmod(uv_fs_t* req, uv_file file, int mode) {
|
657
|
+
int result;
|
658
|
+
HANDLE handle;
|
659
|
+
NTSTATUS nt_status;
|
660
|
+
IO_STATUS_BLOCK io_status;
|
661
|
+
FILE_BASIC_INFORMATION file_info;
|
662
|
+
|
663
|
+
VERIFY_UV_FILE(file, req);
|
664
|
+
|
665
|
+
handle = (HANDLE)_get_osfhandle(file);
|
666
|
+
|
667
|
+
nt_status = pNtQueryInformationFile(handle,
|
668
|
+
&io_status,
|
669
|
+
&file_info,
|
670
|
+
sizeof file_info,
|
671
|
+
FileBasicInformation);
|
672
|
+
|
673
|
+
if (nt_status != STATUS_SUCCESS) {
|
674
|
+
result = -1;
|
675
|
+
goto done;
|
676
|
+
}
|
677
|
+
|
678
|
+
if (mode & _S_IWRITE) {
|
679
|
+
file_info.FileAttributes &= ~FILE_ATTRIBUTE_READONLY;
|
680
|
+
} else {
|
681
|
+
file_info.FileAttributes |= FILE_ATTRIBUTE_READONLY;
|
682
|
+
}
|
683
|
+
|
684
|
+
nt_status = pNtSetInformationFile(handle,
|
685
|
+
&io_status,
|
686
|
+
&file_info,
|
687
|
+
sizeof file_info,
|
688
|
+
FileBasicInformation);
|
689
|
+
|
690
|
+
if (nt_status != STATUS_SUCCESS) {
|
691
|
+
result = -1;
|
692
|
+
goto done;
|
693
|
+
}
|
694
|
+
|
695
|
+
result = 0;
|
696
|
+
|
697
|
+
done:
|
698
|
+
SET_REQ_RESULT(req, result);
|
699
|
+
}
|
700
|
+
|
701
|
+
|
702
|
+
void fs__utime(uv_fs_t* req, const wchar_t* path, double atime, double mtime) {
|
703
|
+
int result;
|
704
|
+
struct _utimbuf b = {(time_t)atime, (time_t)mtime};
|
705
|
+
result = _wutime(path, &b);
|
706
|
+
SET_REQ_RESULT(req, result);
|
707
|
+
}
|
708
|
+
|
709
|
+
|
710
|
+
void fs__futime(uv_fs_t* req, uv_file file, double atime, double mtime) {
|
711
|
+
int result;
|
712
|
+
struct _utimbuf b = {(time_t)atime, (time_t)mtime};
|
713
|
+
|
714
|
+
VERIFY_UV_FILE(file, req);
|
715
|
+
|
716
|
+
result = _futime(file, &b);
|
717
|
+
SET_REQ_RESULT(req, result);
|
718
|
+
}
|
719
|
+
|
720
|
+
|
721
|
+
void fs__link(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path) {
|
722
|
+
int result = CreateHardLinkW(new_path, path, NULL) ? 0 : -1;
|
723
|
+
if (result == -1) {
|
724
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
725
|
+
} else {
|
726
|
+
SET_REQ_RESULT(req, result);
|
727
|
+
}
|
728
|
+
}
|
729
|
+
|
730
|
+
|
731
|
+
void fs__symlink(uv_fs_t* req, const wchar_t* path, const wchar_t* new_path,
|
732
|
+
int flags) {
|
733
|
+
int result;
|
734
|
+
if (pCreateSymbolicLinkW) {
|
735
|
+
result = pCreateSymbolicLinkW(new_path,
|
736
|
+
path,
|
737
|
+
flags & UV_FS_SYMLINK_DIR ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) ? 0 : -1;
|
738
|
+
if (result == -1) {
|
739
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
740
|
+
return;
|
741
|
+
}
|
742
|
+
} else {
|
743
|
+
SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED);
|
744
|
+
return;
|
745
|
+
}
|
746
|
+
|
747
|
+
SET_REQ_RESULT(req, result);
|
748
|
+
}
|
749
|
+
|
750
|
+
|
751
|
+
void fs__readlink(uv_fs_t* req, const wchar_t* path) {
|
752
|
+
int result = -1;
|
753
|
+
BOOL rv;
|
754
|
+
HANDLE symlink;
|
755
|
+
void* buffer = NULL;
|
756
|
+
DWORD bytes_returned;
|
757
|
+
REPARSE_DATA_BUFFER* reparse_data;
|
758
|
+
int utf8size;
|
759
|
+
wchar_t* substitute_name;
|
760
|
+
int substitute_name_length;
|
761
|
+
|
762
|
+
symlink = CreateFileW(path,
|
763
|
+
0,
|
764
|
+
0,
|
765
|
+
NULL,
|
766
|
+
OPEN_EXISTING,
|
767
|
+
FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS,
|
768
|
+
NULL);
|
769
|
+
|
770
|
+
if (INVALID_HANDLE_VALUE == symlink) {
|
771
|
+
result = -1;
|
772
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
773
|
+
goto done;
|
774
|
+
}
|
775
|
+
|
776
|
+
buffer = malloc(MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
|
777
|
+
if (!buffer) {
|
778
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
779
|
+
}
|
780
|
+
|
781
|
+
rv = DeviceIoControl(symlink,
|
782
|
+
FSCTL_GET_REPARSE_POINT,
|
783
|
+
NULL,
|
784
|
+
0,
|
785
|
+
buffer,
|
786
|
+
MAXIMUM_REPARSE_DATA_BUFFER_SIZE,
|
787
|
+
&bytes_returned,
|
788
|
+
NULL);
|
789
|
+
|
790
|
+
if (!rv) {
|
791
|
+
result = -1;
|
792
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
793
|
+
goto done;
|
794
|
+
}
|
795
|
+
|
796
|
+
reparse_data = (REPARSE_DATA_BUFFER*)buffer;
|
797
|
+
if (reparse_data->ReparseTag != IO_REPARSE_TAG_SYMLINK) {
|
798
|
+
result = -1;
|
799
|
+
/* something is seriously wrong */
|
800
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
801
|
+
goto done;
|
802
|
+
}
|
803
|
+
|
804
|
+
substitute_name = reparse_data->SymbolicLinkReparseBuffer.PathBuffer +
|
805
|
+
(reparse_data->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(wchar_t));
|
806
|
+
substitute_name_length =
|
807
|
+
reparse_data->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(wchar_t);
|
808
|
+
|
809
|
+
/* Strip off the leading \??\ from the substitute name buffer.*/
|
810
|
+
if (memcmp(substitute_name, L"\\??\\", 8) == 0) {
|
811
|
+
substitute_name += 4;
|
812
|
+
substitute_name_length -= 4;
|
813
|
+
}
|
814
|
+
|
815
|
+
utf8size = uv_utf16_to_utf8(substitute_name,
|
816
|
+
substitute_name_length,
|
817
|
+
NULL,
|
818
|
+
0);
|
819
|
+
if (!utf8size) {
|
820
|
+
result = -1;
|
821
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
822
|
+
goto done;
|
823
|
+
}
|
824
|
+
|
825
|
+
req->ptr = malloc(utf8size + 1);
|
826
|
+
if (!req->ptr) {
|
827
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
828
|
+
}
|
829
|
+
|
830
|
+
utf8size = uv_utf16_to_utf8(substitute_name,
|
831
|
+
substitute_name_length,
|
832
|
+
(char*)req->ptr,
|
833
|
+
utf8size);
|
834
|
+
if (!utf8size) {
|
835
|
+
result = -1;
|
836
|
+
SET_REQ_WIN32_ERROR(req, GetLastError());
|
837
|
+
goto done;
|
838
|
+
}
|
839
|
+
|
840
|
+
req->flags |= UV_FS_FREE_PTR;
|
841
|
+
((char*)req->ptr)[utf8size] = '\0';
|
842
|
+
result = 0;
|
843
|
+
|
844
|
+
done:
|
845
|
+
if (buffer) {
|
846
|
+
free(buffer);
|
847
|
+
}
|
848
|
+
|
849
|
+
if (symlink != INVALID_HANDLE_VALUE) {
|
850
|
+
CloseHandle(symlink);
|
851
|
+
}
|
852
|
+
|
853
|
+
SET_REQ_RESULT(req, result);
|
854
|
+
}
|
855
|
+
|
856
|
+
|
857
|
+
void fs__nop(uv_fs_t* req) {
|
858
|
+
req->result = 0;
|
859
|
+
}
|
860
|
+
|
861
|
+
|
862
|
+
static DWORD WINAPI uv_fs_thread_proc(void* parameter) {
|
863
|
+
uv_fs_t* req = (uv_fs_t*) parameter;
|
864
|
+
uv_loop_t* loop = req->loop;
|
865
|
+
|
866
|
+
assert(req != NULL);
|
867
|
+
assert(req->type == UV_FS);
|
868
|
+
|
869
|
+
switch (req->fs_type) {
|
870
|
+
case UV_FS_OPEN:
|
871
|
+
fs__open(req, req->pathw, (int)req->arg0, (int)req->arg1);
|
872
|
+
break;
|
873
|
+
case UV_FS_CLOSE:
|
874
|
+
fs__close(req, (uv_file)req->arg0);
|
875
|
+
break;
|
876
|
+
case UV_FS_READ:
|
877
|
+
fs__read(req,
|
878
|
+
(uv_file) req->arg0,
|
879
|
+
req->arg1,
|
880
|
+
(size_t) req->arg2,
|
881
|
+
(off_t) req->arg3);
|
882
|
+
break;
|
883
|
+
case UV_FS_WRITE:
|
884
|
+
fs__write(req,
|
885
|
+
(uv_file)req->arg0,
|
886
|
+
req->arg1,
|
887
|
+
(size_t) req->arg2,
|
888
|
+
(off_t) req->arg3);
|
889
|
+
break;
|
890
|
+
case UV_FS_UNLINK:
|
891
|
+
fs__unlink(req, req->pathw);
|
892
|
+
break;
|
893
|
+
case UV_FS_MKDIR:
|
894
|
+
fs__mkdir(req, req->pathw, (int)req->arg0);
|
895
|
+
break;
|
896
|
+
case UV_FS_RMDIR:
|
897
|
+
fs__rmdir(req, req->pathw);
|
898
|
+
break;
|
899
|
+
case UV_FS_READDIR:
|
900
|
+
fs__readdir(req, req->pathw, (int)req->arg0);
|
901
|
+
break;
|
902
|
+
case UV_FS_STAT:
|
903
|
+
case UV_FS_LSTAT:
|
904
|
+
fs__stat(req, req->pathw);
|
905
|
+
break;
|
906
|
+
case UV_FS_FSTAT:
|
907
|
+
fs__fstat(req, (uv_file)req->arg0);
|
908
|
+
break;
|
909
|
+
case UV_FS_RENAME:
|
910
|
+
fs__rename(req, req->pathw, (const wchar_t*)req->arg0);
|
911
|
+
break;
|
912
|
+
case UV_FS_FSYNC:
|
913
|
+
case UV_FS_FDATASYNC:
|
914
|
+
fs__fsync(req, (uv_file)req->arg0);
|
915
|
+
break;
|
916
|
+
case UV_FS_FTRUNCATE:
|
917
|
+
fs__ftruncate(req, (uv_file)req->arg0, (off_t)req->arg1);
|
918
|
+
break;
|
919
|
+
case UV_FS_SENDFILE:
|
920
|
+
fs__sendfile(req,
|
921
|
+
(uv_file) req->arg0,
|
922
|
+
(uv_file) req->arg1,
|
923
|
+
(off_t) req->arg2,
|
924
|
+
(size_t) req->arg3);
|
925
|
+
break;
|
926
|
+
case UV_FS_CHMOD:
|
927
|
+
fs__chmod(req, req->pathw, (int)req->arg0);
|
928
|
+
break;
|
929
|
+
case UV_FS_FCHMOD:
|
930
|
+
fs__fchmod(req, (uv_file)req->arg0, (int)req->arg1);
|
931
|
+
break;
|
932
|
+
case UV_FS_UTIME:
|
933
|
+
fs__utime(req, req->pathw, req->arg4, req->arg5);
|
934
|
+
break;
|
935
|
+
case UV_FS_FUTIME:
|
936
|
+
fs__futime(req, (uv_file)req->arg0, req->arg4, req->arg5);
|
937
|
+
break;
|
938
|
+
case UV_FS_LINK:
|
939
|
+
fs__link(req, req->pathw, (const wchar_t*)req->arg0);
|
940
|
+
break;
|
941
|
+
case UV_FS_SYMLINK:
|
942
|
+
fs__symlink(req, req->pathw, (const wchar_t*)req->arg0, (int)req->arg1);
|
943
|
+
break;
|
944
|
+
case UV_FS_READLINK:
|
945
|
+
fs__readlink(req, req->pathw);
|
946
|
+
break;
|
947
|
+
case UV_FS_CHOWN:
|
948
|
+
case UV_FS_FCHOWN:
|
949
|
+
fs__nop(req);
|
950
|
+
break;
|
951
|
+
default:
|
952
|
+
assert(!"bad uv_fs_type");
|
953
|
+
}
|
954
|
+
|
955
|
+
POST_COMPLETION_FOR_REQ(loop, req);
|
956
|
+
|
957
|
+
return 0;
|
958
|
+
}
|
959
|
+
|
960
|
+
|
961
|
+
int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
|
962
|
+
int mode, uv_fs_cb cb) {
|
963
|
+
wchar_t* pathw;
|
964
|
+
int size;
|
965
|
+
|
966
|
+
/* Convert to UTF16. */
|
967
|
+
UTF8_TO_UTF16(path, pathw);
|
968
|
+
|
969
|
+
if (cb) {
|
970
|
+
uv_fs_req_init_async(loop, req, UV_FS_OPEN, path, pathw, cb);
|
971
|
+
WRAP_REQ_ARGS2(req, flags, mode);
|
972
|
+
QUEUE_FS_TP_JOB(loop, req);
|
973
|
+
} else {
|
974
|
+
uv_fs_req_init_sync(loop, req, UV_FS_OPEN);
|
975
|
+
fs__open(req, pathw, flags, mode);
|
976
|
+
free(pathw);
|
977
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
978
|
+
return req->result;
|
979
|
+
}
|
980
|
+
|
981
|
+
return 0;
|
982
|
+
}
|
983
|
+
|
984
|
+
|
985
|
+
int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
986
|
+
if (cb) {
|
987
|
+
uv_fs_req_init_async(loop, req, UV_FS_CLOSE, NULL, NULL, cb);
|
988
|
+
WRAP_REQ_ARGS1(req, file);
|
989
|
+
QUEUE_FS_TP_JOB(loop, req);
|
990
|
+
} else {
|
991
|
+
uv_fs_req_init_sync(loop, req, UV_FS_CLOSE);
|
992
|
+
fs__close(req, file);
|
993
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
994
|
+
return req->result;
|
995
|
+
}
|
996
|
+
|
997
|
+
return 0;
|
998
|
+
}
|
999
|
+
|
1000
|
+
|
1001
|
+
int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
|
1002
|
+
size_t length, off_t offset, uv_fs_cb cb) {
|
1003
|
+
if (cb) {
|
1004
|
+
uv_fs_req_init_async(loop, req, UV_FS_READ, NULL, NULL, cb);
|
1005
|
+
WRAP_REQ_ARGS4(req, file, buf, length, offset);
|
1006
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1007
|
+
} else {
|
1008
|
+
uv_fs_req_init_sync(loop, req, UV_FS_READ);
|
1009
|
+
fs__read(req, file, buf, length, offset);
|
1010
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1011
|
+
return req->result;
|
1012
|
+
}
|
1013
|
+
|
1014
|
+
return 0;
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
|
1018
|
+
int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
|
1019
|
+
size_t length, off_t offset, uv_fs_cb cb) {
|
1020
|
+
if (cb) {
|
1021
|
+
uv_fs_req_init_async(loop, req, UV_FS_WRITE, NULL, NULL, cb);
|
1022
|
+
WRAP_REQ_ARGS4(req, file, buf, length, offset);
|
1023
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1024
|
+
} else {
|
1025
|
+
uv_fs_req_init_sync(loop, req, UV_FS_WRITE);
|
1026
|
+
fs__write(req, file, buf, length, offset);
|
1027
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1028
|
+
return req->result;
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
return 0;
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
|
1035
|
+
int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
1036
|
+
uv_fs_cb cb) {
|
1037
|
+
wchar_t* pathw;
|
1038
|
+
int size;
|
1039
|
+
|
1040
|
+
/* Convert to UTF16. */
|
1041
|
+
UTF8_TO_UTF16(path, pathw);
|
1042
|
+
|
1043
|
+
if (cb) {
|
1044
|
+
uv_fs_req_init_async(loop, req, UV_FS_UNLINK, path, pathw, cb);
|
1045
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1046
|
+
} else {
|
1047
|
+
uv_fs_req_init_sync(loop, req, UV_FS_UNLINK);
|
1048
|
+
fs__unlink(req, pathw);
|
1049
|
+
free(pathw);
|
1050
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1051
|
+
return req->result;
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
return 0;
|
1055
|
+
}
|
1056
|
+
|
1057
|
+
|
1058
|
+
int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode,
|
1059
|
+
uv_fs_cb cb) {
|
1060
|
+
wchar_t* pathw;
|
1061
|
+
int size;
|
1062
|
+
|
1063
|
+
/* Convert to UTF16. */
|
1064
|
+
UTF8_TO_UTF16(path, pathw);
|
1065
|
+
|
1066
|
+
if (cb) {
|
1067
|
+
uv_fs_req_init_async(loop, req, UV_FS_MKDIR, path, pathw, cb);
|
1068
|
+
WRAP_REQ_ARGS1(req, mode);
|
1069
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1070
|
+
} else {
|
1071
|
+
uv_fs_req_init_sync(loop, req, UV_FS_MKDIR);
|
1072
|
+
fs__mkdir(req, pathw, mode);
|
1073
|
+
free(pathw);
|
1074
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1075
|
+
return req->result;
|
1076
|
+
}
|
1077
|
+
|
1078
|
+
return 0;
|
1079
|
+
}
|
1080
|
+
|
1081
|
+
|
1082
|
+
int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
1083
|
+
wchar_t* pathw;
|
1084
|
+
int size;
|
1085
|
+
|
1086
|
+
/* Convert to UTF16. */
|
1087
|
+
UTF8_TO_UTF16(path, pathw);
|
1088
|
+
|
1089
|
+
if (cb) {
|
1090
|
+
uv_fs_req_init_async(loop, req, UV_FS_RMDIR, path, pathw, cb);
|
1091
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1092
|
+
} else {
|
1093
|
+
uv_fs_req_init_sync(loop, req, UV_FS_RMDIR);
|
1094
|
+
fs__rmdir(req, pathw);
|
1095
|
+
free(pathw);
|
1096
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1097
|
+
return req->result;
|
1098
|
+
}
|
1099
|
+
|
1100
|
+
return 0;
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
|
1104
|
+
int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
|
1105
|
+
uv_fs_cb cb) {
|
1106
|
+
wchar_t* pathw;
|
1107
|
+
int size;
|
1108
|
+
|
1109
|
+
/* Convert to UTF16. */
|
1110
|
+
UTF8_TO_UTF16(path, pathw);
|
1111
|
+
|
1112
|
+
if (cb) {
|
1113
|
+
uv_fs_req_init_async(loop, req, UV_FS_READDIR, path, pathw, cb);
|
1114
|
+
WRAP_REQ_ARGS1(req, flags);
|
1115
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1116
|
+
} else {
|
1117
|
+
uv_fs_req_init_sync(loop, req, UV_FS_READDIR);
|
1118
|
+
fs__readdir(req, pathw, flags);
|
1119
|
+
free(pathw);
|
1120
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1121
|
+
return req->result;
|
1122
|
+
}
|
1123
|
+
|
1124
|
+
return 0;
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
|
1128
|
+
int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
1129
|
+
const char* new_path, uv_fs_cb cb) {
|
1130
|
+
wchar_t* pathw;
|
1131
|
+
wchar_t* new_pathw;
|
1132
|
+
int size;
|
1133
|
+
|
1134
|
+
/* Convert to UTF16. */
|
1135
|
+
UTF8_TO_UTF16(path, pathw);
|
1136
|
+
UTF8_TO_UTF16(new_path, new_pathw);
|
1137
|
+
|
1138
|
+
if (cb) {
|
1139
|
+
uv_fs_req_init_async(loop, req, UV_FS_LINK, path, pathw, cb);
|
1140
|
+
WRAP_REQ_ARGS1(req, new_pathw);
|
1141
|
+
SET_ALLOCED_ARG(req, 0);
|
1142
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1143
|
+
} else {
|
1144
|
+
uv_fs_req_init_sync(loop, req, UV_FS_LINK);
|
1145
|
+
fs__link(req, pathw, new_pathw);
|
1146
|
+
free(pathw);
|
1147
|
+
free(new_pathw);
|
1148
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1149
|
+
return req->result;
|
1150
|
+
}
|
1151
|
+
|
1152
|
+
return 0;
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
|
1156
|
+
int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
1157
|
+
const char* new_path, int flags, uv_fs_cb cb) {
|
1158
|
+
wchar_t* pathw;
|
1159
|
+
wchar_t* new_pathw;
|
1160
|
+
int size;
|
1161
|
+
|
1162
|
+
/* Convert to UTF16. */
|
1163
|
+
UTF8_TO_UTF16(path, pathw);
|
1164
|
+
UTF8_TO_UTF16(new_path, new_pathw);
|
1165
|
+
|
1166
|
+
if (cb) {
|
1167
|
+
uv_fs_req_init_async(loop, req, UV_FS_SYMLINK, path, pathw, cb);
|
1168
|
+
WRAP_REQ_ARGS2(req, new_pathw, flags);
|
1169
|
+
SET_ALLOCED_ARG(req, 0);
|
1170
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1171
|
+
} else {
|
1172
|
+
uv_fs_req_init_sync(loop, req, UV_FS_SYMLINK);
|
1173
|
+
fs__symlink(req, pathw, new_pathw, flags);
|
1174
|
+
free(pathw);
|
1175
|
+
free(new_pathw);
|
1176
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1177
|
+
return req->result;
|
1178
|
+
}
|
1179
|
+
|
1180
|
+
return 0;
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
|
1184
|
+
int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
1185
|
+
uv_fs_cb cb) {
|
1186
|
+
wchar_t* pathw;
|
1187
|
+
int size;
|
1188
|
+
|
1189
|
+
/* Convert to UTF16. */
|
1190
|
+
UTF8_TO_UTF16(path, pathw);
|
1191
|
+
|
1192
|
+
if (cb) {
|
1193
|
+
uv_fs_req_init_async(loop, req, UV_FS_READLINK, path, pathw, cb);
|
1194
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1195
|
+
} else {
|
1196
|
+
uv_fs_req_init_sync(loop, req, UV_FS_READLINK);
|
1197
|
+
fs__readlink(req, pathw);
|
1198
|
+
free(pathw);
|
1199
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1200
|
+
return req->result;
|
1201
|
+
}
|
1202
|
+
|
1203
|
+
return 0;
|
1204
|
+
}
|
1205
|
+
|
1206
|
+
|
1207
|
+
int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, int uid,
|
1208
|
+
int gid, uv_fs_cb cb) {
|
1209
|
+
wchar_t* pathw;
|
1210
|
+
int size;
|
1211
|
+
|
1212
|
+
/* Convert to UTF16. */
|
1213
|
+
UTF8_TO_UTF16(path, pathw);
|
1214
|
+
|
1215
|
+
if (cb) {
|
1216
|
+
uv_fs_req_init_async(loop, req, UV_FS_CHOWN, path, pathw, cb);
|
1217
|
+
WRAP_REQ_ARGS2(req, uid, gid);
|
1218
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1219
|
+
} else {
|
1220
|
+
uv_fs_req_init_sync(loop, req, UV_FS_CHOWN);
|
1221
|
+
fs__nop(req);
|
1222
|
+
free(pathw);
|
1223
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1224
|
+
return req->result;
|
1225
|
+
}
|
1226
|
+
|
1227
|
+
return 0;
|
1228
|
+
}
|
1229
|
+
|
1230
|
+
|
1231
|
+
int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, int uid,
|
1232
|
+
int gid, uv_fs_cb cb) {
|
1233
|
+
if (cb) {
|
1234
|
+
uv_fs_req_init_async(loop, req, UV_FS_FCHOWN, NULL, NULL, cb);
|
1235
|
+
WRAP_REQ_ARGS3(req, file, uid, gid);
|
1236
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1237
|
+
} else {
|
1238
|
+
uv_fs_req_init_sync(loop, req, UV_FS_FCHOWN);
|
1239
|
+
fs__nop(req);
|
1240
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1241
|
+
return req->result;
|
1242
|
+
}
|
1243
|
+
|
1244
|
+
return 0;
|
1245
|
+
}
|
1246
|
+
|
1247
|
+
|
1248
|
+
int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
1249
|
+
int len = strlen(path);
|
1250
|
+
char* path2 = NULL;
|
1251
|
+
wchar_t* pathw;
|
1252
|
+
int size;
|
1253
|
+
|
1254
|
+
if (len > 1 && path[len - 2] != ':' &&
|
1255
|
+
(path[len - 1] == '\\' || path[len - 1] == '/')) {
|
1256
|
+
path2 = strdup(path);
|
1257
|
+
if (!path2) {
|
1258
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
1259
|
+
}
|
1260
|
+
|
1261
|
+
path2[len - 1] = '\0';
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
if (cb) {
|
1265
|
+
uv_fs_req_init_async(loop, req, UV_FS_STAT, NULL, NULL, cb);
|
1266
|
+
if (path2) {
|
1267
|
+
req->path = path2;
|
1268
|
+
UTF8_TO_UTF16(path2, req->pathw);
|
1269
|
+
} else {
|
1270
|
+
req->path = strdup(path);
|
1271
|
+
UTF8_TO_UTF16(path, req->pathw);
|
1272
|
+
}
|
1273
|
+
|
1274
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1275
|
+
} else {
|
1276
|
+
uv_fs_req_init_sync(loop, req, UV_FS_STAT);
|
1277
|
+
UTF8_TO_UTF16(path2 ? path2 : path, pathw);
|
1278
|
+
fs__stat(req, pathw);
|
1279
|
+
if (path2) {
|
1280
|
+
free(path2);
|
1281
|
+
}
|
1282
|
+
free(pathw);
|
1283
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1284
|
+
return req->result;
|
1285
|
+
}
|
1286
|
+
|
1287
|
+
return 0;
|
1288
|
+
}
|
1289
|
+
|
1290
|
+
|
1291
|
+
/* TODO: add support for links. */
|
1292
|
+
int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
1293
|
+
int len = strlen(path);
|
1294
|
+
char* path2 = NULL;
|
1295
|
+
wchar_t* pathw;
|
1296
|
+
int size;
|
1297
|
+
|
1298
|
+
if (len > 1 && path[len - 2] != ':' &&
|
1299
|
+
(path[len - 1] == '\\' || path[len - 1] == '/')) {
|
1300
|
+
path2 = strdup(path);
|
1301
|
+
if (!path2) {
|
1302
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
1303
|
+
}
|
1304
|
+
|
1305
|
+
path2[len - 1] = '\0';
|
1306
|
+
}
|
1307
|
+
|
1308
|
+
if (cb) {
|
1309
|
+
uv_fs_req_init_async(loop, req, UV_FS_LSTAT, NULL, NULL, cb);
|
1310
|
+
if (path2) {
|
1311
|
+
req->path = path2;
|
1312
|
+
UTF8_TO_UTF16(path2, req->pathw);
|
1313
|
+
} else {
|
1314
|
+
req->path = strdup(path);
|
1315
|
+
UTF8_TO_UTF16(path, req->pathw);
|
1316
|
+
}
|
1317
|
+
|
1318
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1319
|
+
} else {
|
1320
|
+
uv_fs_req_init_sync(loop, req, UV_FS_LSTAT);
|
1321
|
+
UTF8_TO_UTF16(path2 ? path2 : path, pathw);
|
1322
|
+
fs__stat(req, pathw);
|
1323
|
+
if (path2) {
|
1324
|
+
free(path2);
|
1325
|
+
}
|
1326
|
+
free(pathw);
|
1327
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1328
|
+
return req->result;
|
1329
|
+
}
|
1330
|
+
|
1331
|
+
return 0;
|
1332
|
+
}
|
1333
|
+
|
1334
|
+
|
1335
|
+
int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
1336
|
+
if (cb) {
|
1337
|
+
uv_fs_req_init_async(loop, req, UV_FS_FSTAT, NULL, NULL, cb);
|
1338
|
+
WRAP_REQ_ARGS1(req, file);
|
1339
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1340
|
+
} else {
|
1341
|
+
uv_fs_req_init_sync(loop, req, UV_FS_FSTAT);
|
1342
|
+
fs__fstat(req, file);
|
1343
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1344
|
+
return req->result;
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
return 0;
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
|
1351
|
+
int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
1352
|
+
const char* new_path, uv_fs_cb cb) {
|
1353
|
+
wchar_t* pathw;
|
1354
|
+
wchar_t* new_pathw;
|
1355
|
+
int size;
|
1356
|
+
|
1357
|
+
/* Convert to UTF16. */
|
1358
|
+
UTF8_TO_UTF16(path, pathw);
|
1359
|
+
UTF8_TO_UTF16(new_path, new_pathw);
|
1360
|
+
|
1361
|
+
if (cb) {
|
1362
|
+
uv_fs_req_init_async(loop, req, UV_FS_RENAME, path, pathw, cb);
|
1363
|
+
WRAP_REQ_ARGS1(req, new_pathw);
|
1364
|
+
SET_ALLOCED_ARG(req, 0);
|
1365
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1366
|
+
} else {
|
1367
|
+
uv_fs_req_init_sync(loop, req, UV_FS_RENAME);
|
1368
|
+
fs__rename(req, pathw, new_pathw);
|
1369
|
+
free(pathw);
|
1370
|
+
free(new_pathw);
|
1371
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1372
|
+
return req->result;
|
1373
|
+
}
|
1374
|
+
|
1375
|
+
return 0;
|
1376
|
+
}
|
1377
|
+
|
1378
|
+
|
1379
|
+
int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
1380
|
+
if (cb) {
|
1381
|
+
uv_fs_req_init_async(loop, req, UV_FS_FDATASYNC, NULL, NULL, cb);
|
1382
|
+
WRAP_REQ_ARGS1(req, file);
|
1383
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1384
|
+
} else {
|
1385
|
+
uv_fs_req_init_sync(loop, req, UV_FS_FDATASYNC);
|
1386
|
+
fs__fsync(req, file);
|
1387
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1388
|
+
return req->result;
|
1389
|
+
}
|
1390
|
+
|
1391
|
+
return 0;
|
1392
|
+
}
|
1393
|
+
|
1394
|
+
|
1395
|
+
int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
1396
|
+
if (cb) {
|
1397
|
+
uv_fs_req_init_async(loop, req, UV_FS_FSYNC, NULL, NULL, cb);
|
1398
|
+
WRAP_REQ_ARGS1(req, file);
|
1399
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1400
|
+
} else {
|
1401
|
+
uv_fs_req_init_sync(loop, req, UV_FS_FSYNC);
|
1402
|
+
fs__fsync(req, file);
|
1403
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1404
|
+
return req->result;
|
1405
|
+
}
|
1406
|
+
|
1407
|
+
return 0;
|
1408
|
+
}
|
1409
|
+
|
1410
|
+
|
1411
|
+
int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file,
|
1412
|
+
off_t offset, uv_fs_cb cb) {
|
1413
|
+
if (cb) {
|
1414
|
+
uv_fs_req_init_async(loop, req, UV_FS_FTRUNCATE, NULL, NULL, cb);
|
1415
|
+
WRAP_REQ_ARGS2(req, file, offset);
|
1416
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1417
|
+
} else {
|
1418
|
+
uv_fs_req_init_sync(loop, req, UV_FS_FTRUNCATE);
|
1419
|
+
fs__ftruncate(req, file, offset);
|
1420
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1421
|
+
return req->result;
|
1422
|
+
}
|
1423
|
+
|
1424
|
+
return 0;
|
1425
|
+
}
|
1426
|
+
|
1427
|
+
|
1428
|
+
int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd,
|
1429
|
+
uv_file in_fd, off_t in_offset, size_t length, uv_fs_cb cb) {
|
1430
|
+
if (cb) {
|
1431
|
+
uv_fs_req_init_async(loop, req, UV_FS_SENDFILE, NULL, NULL, cb);
|
1432
|
+
WRAP_REQ_ARGS4(req, out_fd, in_fd, in_offset, length);
|
1433
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1434
|
+
} else {
|
1435
|
+
uv_fs_req_init_sync(loop, req, UV_FS_SENDFILE);
|
1436
|
+
fs__sendfile(req, out_fd, in_fd, in_offset, length);
|
1437
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1438
|
+
return req->result;
|
1439
|
+
}
|
1440
|
+
|
1441
|
+
return 0;
|
1442
|
+
}
|
1443
|
+
|
1444
|
+
|
1445
|
+
int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode,
|
1446
|
+
uv_fs_cb cb) {
|
1447
|
+
wchar_t* pathw;
|
1448
|
+
int size;
|
1449
|
+
|
1450
|
+
/* Convert to UTF16. */
|
1451
|
+
UTF8_TO_UTF16(path, pathw);
|
1452
|
+
|
1453
|
+
if (cb) {
|
1454
|
+
uv_fs_req_init_async(loop, req, UV_FS_CHMOD, path, pathw, cb);
|
1455
|
+
WRAP_REQ_ARGS1(req, mode);
|
1456
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1457
|
+
} else {
|
1458
|
+
uv_fs_req_init_sync(loop, req, UV_FS_CHMOD);
|
1459
|
+
fs__chmod(req, pathw, mode);
|
1460
|
+
free(pathw);
|
1461
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1462
|
+
return req->result;
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
return 0;
|
1466
|
+
}
|
1467
|
+
|
1468
|
+
|
1469
|
+
int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file, int mode,
|
1470
|
+
uv_fs_cb cb) {
|
1471
|
+
if (cb) {
|
1472
|
+
uv_fs_req_init_async(loop, req, UV_FS_FCHMOD, NULL, NULL, cb);
|
1473
|
+
WRAP_REQ_ARGS2(req, file, mode);
|
1474
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1475
|
+
} else {
|
1476
|
+
uv_fs_req_init_sync(loop, req, UV_FS_FCHMOD);
|
1477
|
+
fs__fchmod(req, file, mode);
|
1478
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1479
|
+
return req->result;
|
1480
|
+
}
|
1481
|
+
|
1482
|
+
return 0;
|
1483
|
+
}
|
1484
|
+
|
1485
|
+
|
1486
|
+
int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime,
|
1487
|
+
double mtime, uv_fs_cb cb) {
|
1488
|
+
wchar_t* pathw;
|
1489
|
+
int size;
|
1490
|
+
|
1491
|
+
/* Convert to UTF16. */
|
1492
|
+
UTF8_TO_UTF16(path, pathw);
|
1493
|
+
|
1494
|
+
if (cb) {
|
1495
|
+
uv_fs_req_init_async(loop, req, UV_FS_UTIME, path, pathw, cb);
|
1496
|
+
req->arg4 = (ssize_t)atime;
|
1497
|
+
req->arg5 = (ssize_t)mtime;
|
1498
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1499
|
+
} else {
|
1500
|
+
uv_fs_req_init_sync(loop, req, UV_FS_UTIME);
|
1501
|
+
fs__utime(req, pathw, atime, mtime);
|
1502
|
+
free(pathw);
|
1503
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1504
|
+
return req->result;
|
1505
|
+
}
|
1506
|
+
|
1507
|
+
return 0;
|
1508
|
+
}
|
1509
|
+
|
1510
|
+
|
1511
|
+
int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime,
|
1512
|
+
double mtime, uv_fs_cb cb) {
|
1513
|
+
if (cb) {
|
1514
|
+
uv_fs_req_init_async(loop, req, UV_FS_FUTIME, NULL, NULL, cb);
|
1515
|
+
WRAP_REQ_ARGS1(req, file);
|
1516
|
+
req->arg4 = (ssize_t)atime;
|
1517
|
+
req->arg5 = (ssize_t)mtime;
|
1518
|
+
QUEUE_FS_TP_JOB(loop, req);
|
1519
|
+
} else {
|
1520
|
+
uv_fs_req_init_sync(loop, req, UV_FS_FUTIME);
|
1521
|
+
fs__futime(req, file, atime, mtime);
|
1522
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1523
|
+
return req->result;
|
1524
|
+
}
|
1525
|
+
|
1526
|
+
return 0;
|
1527
|
+
}
|
1528
|
+
|
1529
|
+
|
1530
|
+
void uv_process_fs_req(uv_loop_t* loop, uv_fs_t* req) {
|
1531
|
+
assert(req->cb);
|
1532
|
+
SET_UV_LAST_ERROR_FROM_REQ(req);
|
1533
|
+
req->cb(req);
|
1534
|
+
}
|
1535
|
+
|
1536
|
+
|
1537
|
+
void uv_fs_req_cleanup(uv_fs_t* req) {
|
1538
|
+
uv_loop_t* loop = req->loop;
|
1539
|
+
|
1540
|
+
if (req->flags & UV_FS_CLEANEDUP) {
|
1541
|
+
return;
|
1542
|
+
}
|
1543
|
+
|
1544
|
+
if (req->flags & UV_FS_FREE_ARG0 && req->arg0) {
|
1545
|
+
free(req->arg0);
|
1546
|
+
req->arg0 = NULL;
|
1547
|
+
}
|
1548
|
+
|
1549
|
+
if (req->flags & UV_FS_FREE_ARG1 && req->arg1) {
|
1550
|
+
free(req->arg1);
|
1551
|
+
req->arg1 = NULL;
|
1552
|
+
}
|
1553
|
+
|
1554
|
+
if (req->flags & UV_FS_FREE_PTR && req->ptr) {
|
1555
|
+
free(req->ptr);
|
1556
|
+
}
|
1557
|
+
|
1558
|
+
req->ptr = NULL;
|
1559
|
+
|
1560
|
+
if (req->path) {
|
1561
|
+
free(req->path);
|
1562
|
+
req->path = NULL;
|
1563
|
+
}
|
1564
|
+
|
1565
|
+
if (req->pathw) {
|
1566
|
+
free(req->pathw);
|
1567
|
+
req->pathw = NULL;
|
1568
|
+
}
|
1569
|
+
|
1570
|
+
if (req->flags & UV_FS_ASYNC_QUEUED) {
|
1571
|
+
uv_unref(loop);
|
1572
|
+
}
|
1573
|
+
|
1574
|
+
req->flags |= UV_FS_CLEANEDUP;
|
1575
|
+
}
|
1576
|
+
|