@scriptc/cli-darwin-x64 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD_PARTY_NOTICES +1 -1
- package/dist/bin/scriptc +0 -0
- package/dist/bin/scriptc.json +1 -1
- package/dist/lib/declarations/scriptc-node-fallback.d.ts +84 -19
- package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
- package/dist/lib/llvm/package.json +1 -1
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_web.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/licenses/v8-number-radix.txt +61 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_web.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/package.json +1 -1
- package/dist/lib/runtime-darwin-x64/runtime-pack.json +549 -545
- package/dist/lib/runtime-sources/package.json +1 -1
- package/dist/lib/runtime-sources/src/scr_abort.c +5 -0
- package/dist/lib/runtime-sources/src/scr_array.c +16 -0
- package/dist/lib/runtime-sources/src/scr_assert.c +1 -0
- package/dist/lib/runtime-sources/src/scr_async.c +38 -5
- package/dist/lib/runtime-sources/src/scr_async_dyn.c +208 -40
- package/dist/lib/runtime-sources/src/scr_bigint.c +8 -0
- package/dist/lib/runtime-sources/src/scr_bytes.c +431 -41
- package/dist/lib/runtime-sources/src/scr_bytes_io.c +628 -12
- package/dist/lib/runtime-sources/src/scr_child.c +544 -17
- package/dist/lib/runtime-sources/src/scr_console.c +1 -1
- package/dist/lib/runtime-sources/src/scr_crypto_async.c +22 -2
- package/dist/lib/runtime-sources/src/scr_dyn_invoke.c +344 -73
- package/dist/lib/runtime-sources/src/scr_error.c +52 -5
- package/dist/lib/runtime-sources/src/scr_exception.c +21 -5
- package/dist/lib/runtime-sources/src/scr_fetch.c +311 -3
- package/dist/lib/runtime-sources/src/scr_file_handle.c +31 -0
- package/dist/lib/runtime-sources/src/scr_http.c +3 -0
- package/dist/lib/runtime-sources/src/scr_island.c +1226 -405
- package/dist/lib/runtime-sources/src/scr_island_manifest.h +11 -9
- package/dist/lib/runtime-sources/src/scr_json.c +1594 -139
- package/dist/lib/runtime-sources/src/scr_json.test.ts +1 -0
- package/dist/lib/runtime-sources/src/scr_lib.c +816 -34
- package/dist/lib/runtime-sources/src/scr_map.c +47 -0
- package/dist/lib/runtime-sources/src/scr_node_builtin.c +10 -0
- package/dist/lib/runtime-sources/src/scr_object.c +11 -0
- package/dist/lib/runtime-sources/src/scr_qs.c +10 -0
- package/dist/lib/runtime-sources/src/scr_regex.c +148 -72
- package/dist/lib/runtime-sources/src/scr_runtime.h +257 -41
- package/dist/lib/runtime-sources/src/scr_stream.c +197 -0
- package/dist/lib/runtime-sources/src/scr_string.c +16 -1
- package/dist/lib/runtime-sources/src/scr_symbol.c +5 -0
- package/dist/lib/runtime-sources/src/scr_text_decoder_labels.h +225 -0
- package/dist/lib/runtime-sources/src/scr_url.c +206 -10
- package/dist/lib/runtime-sources/src/scr_web.c +129 -26
- package/dist/lib/runtime-sources/vendor/v8-number-radix/LICENSE +61 -0
- package/package.json +1 -1
|
@@ -12,6 +12,21 @@
|
|
|
12
12
|
#include <stdlib.h>
|
|
13
13
|
#include <string.h>
|
|
14
14
|
#include <time.h>
|
|
15
|
+
#include <fcntl.h>
|
|
16
|
+
#include <dirent.h>
|
|
17
|
+
#include <sys/stat.h>
|
|
18
|
+
#include <unistd.h>
|
|
19
|
+
#include <utime.h>
|
|
20
|
+
#ifndef O_SYNC
|
|
21
|
+
#define O_SYNC 0 /* Windows CRT opens have no separate synchronous flag. */
|
|
22
|
+
#endif
|
|
23
|
+
/* Bionic added glob/globfree in API 28; Android packs target API 26. */
|
|
24
|
+
#if !defined(_WIN32) && !defined(__wasi__) && (!defined(__ANDROID__) || __ANDROID_API__ >= 28)
|
|
25
|
+
#include <glob.h>
|
|
26
|
+
#define SCR_FS_HAS_GLOB 1
|
|
27
|
+
#else
|
|
28
|
+
#define SCR_FS_HAS_GLOB 0
|
|
29
|
+
#endif
|
|
15
30
|
#ifdef __APPLE__
|
|
16
31
|
#include <sys/stat.h> /* lchmod(2) — the fs.lchmodSync ladder's real tail */
|
|
17
32
|
#endif
|
|
@@ -140,6 +155,595 @@ ScrPromise *scr_fsp_read_file_bytes(ScrStr *path) {
|
|
|
140
155
|
return scr_promise_settled_ref(b, &scr_bytes_retain_v, &scr_bytes_release_v, NULL);
|
|
141
156
|
}
|
|
142
157
|
|
|
158
|
+
/* Native error-first callbacks remain callable values when a platform layer
|
|
159
|
+
* captures them. Argument failures throw at the call; filesystem failures
|
|
160
|
+
* arrive through the callback on the next event-loop turn. The synchronous
|
|
161
|
+
* filesystem spine does the work, as it does for our promise adapters. */
|
|
162
|
+
static bool scr_fs_dyn_absent(const ScrDyn *value);
|
|
163
|
+
static bool scr_fs_cb_chk(const ScrDyn *callback, const char *name);
|
|
164
|
+
static bool scr_fs_path_chk(const ScrDyn *value, const char *name);
|
|
165
|
+
static ScrDyn *scr_fs_cb_arg(ScrDyn *const *args, size_t argc, size_t index) {
|
|
166
|
+
return index < argc ? args[index] : scr_dyn_undefined();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
static ScrDyn *scr_fs_cb_option(const ScrDyn *options, const char *name) {
|
|
170
|
+
if (scr_fs_dyn_absent(options)) return scr_dyn_retain(scr_dyn_undefined());
|
|
171
|
+
ScrDyn *object = options->kind == SCR_DYN_TYPED_REF ? scr_dyn_typed_ref_materialize(options) : scr_dyn_retain((ScrDyn *)options);
|
|
172
|
+
if (!object) return NULL;
|
|
173
|
+
ScrDyn *value = scr_dyn_obj_read(object, name, strlen(name));
|
|
174
|
+
scr_dyn_release(object);
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static double scr_fs_cb_number(const ScrDyn *value, const char *name, double fallback) {
|
|
179
|
+
if (scr_fs_dyn_absent(value)) return fallback;
|
|
180
|
+
if (value->kind == SCR_DYN_BIGINT) return scr_bigint_to_f64(value->v.bigint);
|
|
181
|
+
if (value->kind != SCR_DYN_NUM) {
|
|
182
|
+
scr_dyn_arg_type_fail(name, "of type number", value);
|
|
183
|
+
return fallback;
|
|
184
|
+
}
|
|
185
|
+
return value->v.num;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
static double scr_fs_cb_option_number(const ScrDyn *options, const char *name, double fallback) {
|
|
189
|
+
ScrDyn *value = scr_fs_cb_option(options, name);
|
|
190
|
+
if (!value) return fallback;
|
|
191
|
+
double number = scr_fs_cb_number(value, name, fallback);
|
|
192
|
+
scr_dyn_release(value);
|
|
193
|
+
return number;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
static bool scr_fs_cb_option_bool(const ScrDyn *options, const char *name) {
|
|
197
|
+
ScrDyn *value = scr_fs_cb_option(options, name);
|
|
198
|
+
bool answer = value && scr_dyn_truthy(value);
|
|
199
|
+
scr_dyn_release(value);
|
|
200
|
+
return answer;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
static bool scr_fs_cb_refuse_option(const ScrDyn *options, const char *name) {
|
|
204
|
+
ScrDyn *value = scr_fs_cb_option(options, name);
|
|
205
|
+
bool present = value && value->kind != SCR_DYN_UNDEF && value->kind != SCR_DYN_NULL;
|
|
206
|
+
scr_dyn_release(value);
|
|
207
|
+
if (present) {
|
|
208
|
+
char message[160];
|
|
209
|
+
int length = snprintf(message, sizeof message, "Filesystem callback option '%s' has no native lowering", name);
|
|
210
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, (size_t)length, "SC2020");
|
|
211
|
+
}
|
|
212
|
+
return present;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
static bool scr_fs_cb_signal(const ScrDyn *options) {
|
|
216
|
+
ScrDyn *signal = scr_fs_cb_option(options, "signal");
|
|
217
|
+
if (!signal) return false;
|
|
218
|
+
if (scr_fs_dyn_absent(signal)) { scr_dyn_release(signal); return true; }
|
|
219
|
+
if (signal->kind != SCR_DYN_HANDLE || signal->v.handle.tag != SCR_DYNH_ABORT_SIGNAL) {
|
|
220
|
+
scr_dyn_arg_type_fail("options.signal", "an instance of AbortSignal", signal);
|
|
221
|
+
scr_dyn_release(signal);
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
ScrStr *key = scr_str_new("aborted", 7);
|
|
225
|
+
ScrDyn *aborted = scr_dyn_handle_key_get(signal, key);
|
|
226
|
+
scr_str_release(key);
|
|
227
|
+
bool cancelled = aborted && scr_dyn_truthy(aborted);
|
|
228
|
+
scr_dyn_release(aborted); scr_dyn_release(signal);
|
|
229
|
+
if (cancelled) {
|
|
230
|
+
static const char message[] = "The operation was aborted";
|
|
231
|
+
ScrStr *text = scr_str_new(message, sizeof message - 1);
|
|
232
|
+
ScrError *error = scr_error_new(SCR_ERR_ERROR, text);
|
|
233
|
+
scr_str_release(text);
|
|
234
|
+
scr_str_release(error->name);
|
|
235
|
+
error->name = scr_str_new("AbortError", 10);
|
|
236
|
+
error->name_present = true;
|
|
237
|
+
scr_error_set_code(error, "ABORT_ERR");
|
|
238
|
+
scr_throw_obj(error, scr_error_retain_v, scr_error_release_v, scr_error_trace_arg());
|
|
239
|
+
}
|
|
240
|
+
return !scr_exc_pending();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
static double scr_fs_cb_open(const ScrStr *path, const ScrDyn *flag, double mode, const char *fallback) {
|
|
244
|
+
const char *f = flag->kind == SCR_DYN_UNDEF ? fallback : flag->kind == SCR_DYN_STR ? flag->v.str->data : NULL;
|
|
245
|
+
if (!f) {
|
|
246
|
+
static const char message[] = "Runtime numeric filesystem flags have no portable native lowering";
|
|
247
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, sizeof message - 1, "SC2020");
|
|
248
|
+
return -1;
|
|
249
|
+
}
|
|
250
|
+
int bits;
|
|
251
|
+
if (!strcmp(f, "r")) bits = O_RDONLY;
|
|
252
|
+
else if (!strcmp(f, "r+")) bits = O_RDWR;
|
|
253
|
+
else if (!strcmp(f, "rs") || !strcmp(f, "sr")) bits = O_RDONLY | O_SYNC;
|
|
254
|
+
else if (!strcmp(f, "rs+") || !strcmp(f, "sr+")) bits = O_RDWR | O_SYNC;
|
|
255
|
+
else if (!strcmp(f, "w")) bits = O_WRONLY | O_CREAT | O_TRUNC;
|
|
256
|
+
else if (!strcmp(f, "w+")) bits = O_RDWR | O_CREAT | O_TRUNC;
|
|
257
|
+
else if (!strcmp(f, "wx") || !strcmp(f, "xw")) bits = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL;
|
|
258
|
+
else if (!strcmp(f, "wx+") || !strcmp(f, "xw+")) bits = O_RDWR | O_CREAT | O_TRUNC | O_EXCL;
|
|
259
|
+
else if (!strcmp(f, "a")) bits = O_WRONLY | O_CREAT | O_APPEND;
|
|
260
|
+
else if (!strcmp(f, "a+")) bits = O_RDWR | O_CREAT | O_APPEND;
|
|
261
|
+
else if (!strcmp(f, "ax") || !strcmp(f, "xa")) bits = O_WRONLY | O_CREAT | O_APPEND | O_EXCL;
|
|
262
|
+
else if (!strcmp(f, "ax+") || !strcmp(f, "xa+")) bits = O_RDWR | O_CREAT | O_APPEND | O_EXCL;
|
|
263
|
+
else if (!strcmp(f, "as") || !strcmp(f, "sa")) bits = O_WRONLY | O_CREAT | O_APPEND | O_SYNC;
|
|
264
|
+
else if (!strcmp(f, "as+") || !strcmp(f, "sa+")) bits = O_RDWR | O_CREAT | O_APPEND | O_SYNC;
|
|
265
|
+
else {
|
|
266
|
+
char message[160];
|
|
267
|
+
int length = snprintf(message, sizeof message, "The argument 'flags' is invalid. Received '%s'", f);
|
|
268
|
+
scr_throw_error_msg_code(SCR_ERR_TYPE, message, (size_t)length, "ERR_INVALID_ARG_VALUE");
|
|
269
|
+
return -1;
|
|
270
|
+
}
|
|
271
|
+
if (scr_exc_pending()) return -1;
|
|
272
|
+
int fd = open(path->data, bits, (mode_t)mode);
|
|
273
|
+
if (fd < 0) scr_fs_throw(errno, "open", path);
|
|
274
|
+
return fd;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
static ScrStr *scr_fs_cb_path(const ScrDyn *value, const char *name) {
|
|
278
|
+
if (!scr_fs_path_chk(value, name)) return NULL;
|
|
279
|
+
ScrStr *path = value->kind == SCR_DYN_STR ? scr_str_retain(value->v.str)
|
|
280
|
+
: scr_str_new((const char *)value->v.bytes->data, value->v.bytes->len);
|
|
281
|
+
if (memchr(path->data, 0, path->len)) {
|
|
282
|
+
scr_dyn_arg_value_fail(name, "must be a string, Uint8Array, or URL without null bytes", value);
|
|
283
|
+
scr_str_release(path);
|
|
284
|
+
return NULL;
|
|
285
|
+
}
|
|
286
|
+
return path;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
static ScrDyn *scr_fs_cb_string(ScrStr *text) {
|
|
290
|
+
if (!text) return NULL;
|
|
291
|
+
ScrDyn *value = scr_dyn_new_str(text);
|
|
292
|
+
scr_str_release(text);
|
|
293
|
+
return value;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
static ScrStr *scr_fs_cb_join(const ScrStr *directory, const char *name) {
|
|
297
|
+
ScrStr *suffix = scr_str_new("/", 1);
|
|
298
|
+
ScrStr *base = scr_str_concat((ScrStr *)directory, suffix);
|
|
299
|
+
scr_str_release(suffix);
|
|
300
|
+
suffix = scr_str_new(name, strlen(name));
|
|
301
|
+
ScrStr *path = scr_str_concat(base, suffix);
|
|
302
|
+
scr_str_release(base); scr_str_release(suffix);
|
|
303
|
+
return path;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
static void scr_fs_cb_copy(const ScrStr *source, const ScrStr *destination, bool recursive, bool force, bool preserve) {
|
|
307
|
+
struct stat status;
|
|
308
|
+
if (
|
|
309
|
+
#ifdef _WIN32
|
|
310
|
+
stat(source->data, &status)
|
|
311
|
+
#else
|
|
312
|
+
lstat(source->data, &status)
|
|
313
|
+
#endif
|
|
314
|
+
< 0) { scr_fs_throw(errno, "stat", source); return; }
|
|
315
|
+
#ifndef _WIN32
|
|
316
|
+
if (S_ISLNK(status.st_mode)) {
|
|
317
|
+
const char *message = "Symbolic-link cp entries have no native lowering";
|
|
318
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, strlen(message), "SC2020");
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
#endif
|
|
322
|
+
if (S_ISDIR(status.st_mode)) {
|
|
323
|
+
if (!recursive) { scr_fs_throw(EISDIR, "cp", source); return; }
|
|
324
|
+
scr_fs_mkdir_recursive_mode((ScrStr *)destination, status.st_mode & 0777);
|
|
325
|
+
if (scr_exc_pending()) return;
|
|
326
|
+
DIR *directory = opendir(source->data);
|
|
327
|
+
if (!directory) { scr_fs_throw(errno, "opendir", source); return; }
|
|
328
|
+
struct dirent *entry;
|
|
329
|
+
while (!scr_exc_pending() && (entry = readdir(directory))) {
|
|
330
|
+
if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) continue;
|
|
331
|
+
ScrStr *from = scr_fs_cb_join(source, entry->d_name), *to = scr_fs_cb_join(destination, entry->d_name);
|
|
332
|
+
scr_fs_cb_copy(from, to, true, force, preserve);
|
|
333
|
+
scr_str_release(from); scr_str_release(to);
|
|
334
|
+
}
|
|
335
|
+
closedir(directory);
|
|
336
|
+
} else {
|
|
337
|
+
if (!force && scr_fs_exists((ScrStr *)destination)) return;
|
|
338
|
+
scr_fs_copyfile((ScrStr *)source, (ScrStr *)destination);
|
|
339
|
+
}
|
|
340
|
+
if (preserve && !scr_exc_pending()) {
|
|
341
|
+
struct utimbuf times = { status.st_atime, status.st_mtime };
|
|
342
|
+
if (utime(destination->data, ×) < 0) scr_fs_throw(errno, "utime", destination);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
static ScrDyn *scr_fs_cb_stat_test(ScrClosure *closure, ScrDyn *const *args, size_t argc) {
|
|
347
|
+
(void)args; (void)argc;
|
|
348
|
+
return scr_dyn_new_bool(scr_box_get_bool(closure->caps[0]));
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
static void scr_fs_cb_stat_method(ScrDyn *object, const char *name, bool answer) {
|
|
352
|
+
ScrClosure *closure = scr_closure_new(NULL, 1);
|
|
353
|
+
closure->caps[0] = scr_box_new(SCR_BOX_BOOL);
|
|
354
|
+
scr_box_set_bool(closure->caps[0], answer);
|
|
355
|
+
scr_dyn_obj_set(object, name, strlen(name), scr_dyn_new_func(closure, scr_fs_cb_stat_test, 0, "native:fs.Stats", name));
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
static void scr_fs_cb_stat_number(ScrDyn *object, const char *name, int64_t number, bool bigint) {
|
|
359
|
+
ScrDyn *value;
|
|
360
|
+
if (bigint) {
|
|
361
|
+
ScrBigInt *integer = scr_bigint_from_i64(number);
|
|
362
|
+
value = scr_dyn_new_bigint(integer);
|
|
363
|
+
scr_bigint_release(integer);
|
|
364
|
+
} else value = scr_dyn_new_num((double)number);
|
|
365
|
+
scr_dyn_obj_set(object, name, strlen(name), value);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
static void scr_fs_cb_stat_date(ScrDyn *object, const char *name, double milliseconds) {
|
|
369
|
+
ScrDyn *arguments = scr_dyn_new_arr();
|
|
370
|
+
scr_dyn_arr_push(arguments, scr_dyn_new_num(milliseconds));
|
|
371
|
+
ScrDyn *date = scr_dyn_native_date_new(arguments);
|
|
372
|
+
scr_dyn_release(arguments);
|
|
373
|
+
if (date) scr_dyn_obj_set(object, name, strlen(name), date);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
static ScrDyn *scr_fs_cb_stats(const ScrStr *path, double fd, const ScrDyn *options, bool nofollow) {
|
|
377
|
+
struct stat status;
|
|
378
|
+
#ifdef _WIN32
|
|
379
|
+
(void)nofollow;
|
|
380
|
+
int rc = path ? stat(path->data, &status) : fstat((int)fd, &status);
|
|
381
|
+
#else
|
|
382
|
+
int rc = path ? (nofollow ? lstat(path->data, &status) : stat(path->data, &status)) : fstat((int)fd, &status);
|
|
383
|
+
#endif
|
|
384
|
+
if (rc < 0) { scr_fs_throw(errno, path ? (nofollow ? "lstat" : "stat") : "fstat", path); return NULL; }
|
|
385
|
+
bool bigint = scr_fs_cb_option_bool(options, "bigint");
|
|
386
|
+
ScrDyn *object = scr_dyn_new_obj();
|
|
387
|
+
#define SCR_FS_STAT_FIELD(field) scr_fs_cb_stat_number(object, #field, (int64_t)status.st_##field, bigint)
|
|
388
|
+
SCR_FS_STAT_FIELD(dev); SCR_FS_STAT_FIELD(ino); SCR_FS_STAT_FIELD(mode); SCR_FS_STAT_FIELD(nlink);
|
|
389
|
+
SCR_FS_STAT_FIELD(uid); SCR_FS_STAT_FIELD(gid); SCR_FS_STAT_FIELD(rdev); SCR_FS_STAT_FIELD(size);
|
|
390
|
+
#ifndef _WIN32
|
|
391
|
+
SCR_FS_STAT_FIELD(blksize); SCR_FS_STAT_FIELD(blocks);
|
|
392
|
+
#endif
|
|
393
|
+
#undef SCR_FS_STAT_FIELD
|
|
394
|
+
double atime = (double)status.st_atime * 1000, mtime = (double)status.st_mtime * 1000, ctime = (double)status.st_ctime * 1000;
|
|
395
|
+
double birthtime = 0;
|
|
396
|
+
#ifdef __APPLE__
|
|
397
|
+
atime += status.st_atimespec.tv_nsec / 1000000.0; mtime += status.st_mtimespec.tv_nsec / 1000000.0;
|
|
398
|
+
ctime += status.st_ctimespec.tv_nsec / 1000000.0;
|
|
399
|
+
birthtime = (double)status.st_birthtimespec.tv_sec * 1000 + status.st_birthtimespec.tv_nsec / 1000000.0;
|
|
400
|
+
#elif !defined(_WIN32) && !defined(__wasi__)
|
|
401
|
+
atime += status.st_atim.tv_nsec / 1000000.0; mtime += status.st_mtim.tv_nsec / 1000000.0;
|
|
402
|
+
ctime += status.st_ctim.tv_nsec / 1000000.0;
|
|
403
|
+
#endif
|
|
404
|
+
scr_fs_cb_stat_date(object, "atime", atime); scr_fs_cb_stat_date(object, "mtime", mtime);
|
|
405
|
+
scr_fs_cb_stat_date(object, "ctime", ctime); scr_fs_cb_stat_date(object, "birthtime", birthtime);
|
|
406
|
+
if (bigint) {
|
|
407
|
+
scr_fs_cb_stat_number(object, "atimeMs", (int64_t)atime, true);
|
|
408
|
+
scr_fs_cb_stat_number(object, "mtimeMs", (int64_t)mtime, true);
|
|
409
|
+
scr_fs_cb_stat_number(object, "ctimeMs", (int64_t)ctime, true);
|
|
410
|
+
scr_fs_cb_stat_number(object, "birthtimeMs", (int64_t)birthtime, true);
|
|
411
|
+
} else {
|
|
412
|
+
scr_dyn_obj_set(object, "atimeMs", 7, scr_dyn_new_num(atime));
|
|
413
|
+
scr_dyn_obj_set(object, "mtimeMs", 7, scr_dyn_new_num(mtime));
|
|
414
|
+
scr_dyn_obj_set(object, "ctimeMs", 7, scr_dyn_new_num(ctime));
|
|
415
|
+
scr_dyn_obj_set(object, "birthtimeMs", 11, scr_dyn_new_num(birthtime));
|
|
416
|
+
}
|
|
417
|
+
scr_fs_cb_stat_method(object, "isFile", S_ISREG(status.st_mode));
|
|
418
|
+
scr_fs_cb_stat_method(object, "isDirectory", S_ISDIR(status.st_mode));
|
|
419
|
+
#ifndef _WIN32
|
|
420
|
+
scr_fs_cb_stat_method(object, "isSymbolicLink", S_ISLNK(status.st_mode));
|
|
421
|
+
scr_fs_cb_stat_method(object, "isBlockDevice", S_ISBLK(status.st_mode));
|
|
422
|
+
scr_fs_cb_stat_method(object, "isCharacterDevice", S_ISCHR(status.st_mode));
|
|
423
|
+
scr_fs_cb_stat_method(object, "isFIFO", S_ISFIFO(status.st_mode));
|
|
424
|
+
scr_fs_cb_stat_method(object, "isSocket", S_ISSOCK(status.st_mode));
|
|
425
|
+
#else
|
|
426
|
+
scr_fs_cb_stat_method(object, "isSymbolicLink", false);
|
|
427
|
+
scr_fs_cb_stat_method(object, "isBlockDevice", false);
|
|
428
|
+
scr_fs_cb_stat_method(object, "isCharacterDevice", S_ISCHR(status.st_mode));
|
|
429
|
+
scr_fs_cb_stat_method(object, "isFIFO", false); scr_fs_cb_stat_method(object, "isSocket", false);
|
|
430
|
+
#endif
|
|
431
|
+
return object;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
#ifndef SCR_LIB
|
|
435
|
+
static void scr_fs_cb_fire(ScrClosure *closure) {
|
|
436
|
+
ScrDyn *callback = scr_box_get_ref(closure->caps[0]);
|
|
437
|
+
ScrDyn *arguments = scr_box_get_ref(closure->caps[1]);
|
|
438
|
+
ScrDyn *result = scr_dyn_apply(callback, arguments, "the filesystem callback");
|
|
439
|
+
scr_dyn_release(result); scr_dyn_release(callback); scr_dyn_release(arguments);
|
|
440
|
+
}
|
|
441
|
+
#endif
|
|
442
|
+
|
|
443
|
+
static void scr_fs_cb_schedule(const ScrDyn *callback, ScrDyn *result, const ScrDyn *buffer) {
|
|
444
|
+
ScrDyn *arguments = scr_dyn_new_arr();
|
|
445
|
+
if (scr_exc_pending()) {
|
|
446
|
+
ScrCaught *caught = scr_exc_take();
|
|
447
|
+
ScrDyn *error = scr_caught_to_dyn(caught);
|
|
448
|
+
scr_caught_release(caught);
|
|
449
|
+
scr_dyn_arr_push(arguments, error);
|
|
450
|
+
scr_dyn_release(result);
|
|
451
|
+
} else {
|
|
452
|
+
scr_dyn_arr_push(arguments, scr_dyn_new_null());
|
|
453
|
+
if (result) scr_dyn_arr_push(arguments, result);
|
|
454
|
+
if (buffer) scr_dyn_arr_push(arguments, scr_dyn_retain((ScrDyn *)buffer));
|
|
455
|
+
}
|
|
456
|
+
#ifndef SCR_LIB
|
|
457
|
+
ScrClosure *closure = scr_closure_new((void *)scr_fs_cb_fire, 2);
|
|
458
|
+
closure->caps[0] = scr_box_new_obj(scr_dyn_retain_v, scr_dyn_release_v, scr_dyn_trace_v);
|
|
459
|
+
closure->caps[1] = scr_box_new_obj(scr_dyn_retain_v, scr_dyn_release_v, scr_dyn_trace_v);
|
|
460
|
+
scr_box_set_ref(closure->caps[0], scr_dyn_retain((ScrDyn *)callback));
|
|
461
|
+
scr_box_set_ref(closure->caps[1], arguments);
|
|
462
|
+
scr_set_timeout(closure, 0);
|
|
463
|
+
#else
|
|
464
|
+
(void)callback;
|
|
465
|
+
scr_dyn_release(arguments);
|
|
466
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, "Filesystem callbacks require an executable event loop", 52, "SC4005");
|
|
467
|
+
#endif
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
static bool scr_fs_read_validate(const ScrDyn *, const ScrDyn *, const ScrDyn *, const ScrDyn *, const ScrDyn *);
|
|
471
|
+
static bool scr_fs_encoding_chk(const ScrDyn *);
|
|
472
|
+
static bool scr_fs_int_range_chk(const ScrDyn *, const char *, double, double, const char *);
|
|
473
|
+
static bool scr_fs_mode_chk(const ScrDyn *, const char *);
|
|
474
|
+
|
|
475
|
+
static ScrArr *scr_fs_cb_vectors(const ScrDyn *buffers) {
|
|
476
|
+
ScrDyn *snapshot = buffers->kind == SCR_DYN_TYPED_REF && scr_dyn_isl_is_array(buffers)
|
|
477
|
+
? scr_dyn_typed_ref_materialize(buffers) : NULL;
|
|
478
|
+
const ScrDyn *array = snapshot ? snapshot : buffers;
|
|
479
|
+
if (array->kind != SCR_DYN_ARR) {
|
|
480
|
+
scr_dyn_arg_type_fail("buffers", "an instance of Array", buffers);
|
|
481
|
+
scr_dyn_release(snapshot);
|
|
482
|
+
return NULL;
|
|
483
|
+
}
|
|
484
|
+
ScrArr *out = scr_arr_new_ref(scr_bytes_retain_v, scr_bytes_release_v, NULL, array->v.arr.len);
|
|
485
|
+
for (size_t i = 0; i < array->v.arr.len; i++) {
|
|
486
|
+
const ScrDyn *buffer = array->v.arr.items[i];
|
|
487
|
+
if (!scr_dyn_bytes_is(buffer, SCR_BYTES_U8)) {
|
|
488
|
+
scr_dyn_arg_type_fail("buffers", "an Array of ArrayBufferView", buffers);
|
|
489
|
+
scr_arr_release(out);
|
|
490
|
+
scr_dyn_release(snapshot);
|
|
491
|
+
return NULL;
|
|
492
|
+
}
|
|
493
|
+
/* push_ref consumes the reference produced by unbox. */
|
|
494
|
+
scr_arr_push_ref(out, scr_dyn_bytes_unbox(buffer));
|
|
495
|
+
}
|
|
496
|
+
scr_dyn_release(snapshot);
|
|
497
|
+
return out;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
static ScrDyn *scr_fs_cb_invoke(ScrStr *member, ScrDyn *const *args, size_t argc) {
|
|
501
|
+
const char *op = member->data;
|
|
502
|
+
bool vector = !strcmp(op, "readv") || !strcmp(op, "writev");
|
|
503
|
+
bool newControl = !strcmp(op, "fdatasync") || !strcmp(op, "fchmod") || !strcmp(op, "ftruncate");
|
|
504
|
+
if ((vector || newControl) && !scr_fs_int_range_chk(scr_fs_cb_arg(args, argc, 0), "fd", 0, 2147483647.0, ">= 0 && <= 2147483647")) return NULL;
|
|
505
|
+
ScrArr *vectors = vector ? scr_fs_cb_vectors(scr_fs_cb_arg(args, argc, 1)) : NULL;
|
|
506
|
+
if (vector && !vectors) return NULL;
|
|
507
|
+
bool fileCallback = !strcmp(op, "readFile") || !strcmp(op, "mkdtemp");
|
|
508
|
+
const ScrDyn *callback = argc >= (fileCallback ? 2u : 1u) ? args[argc - 1] : scr_dyn_undefined();
|
|
509
|
+
if (!scr_fs_cb_chk(callback, fileCallback || vector ? "cb" : "callback")) { scr_arr_release(vectors); return NULL; }
|
|
510
|
+
size_t count = argc - 1;
|
|
511
|
+
#define ARG(index) scr_fs_cb_arg(args, count, index)
|
|
512
|
+
if (!strcmp(op, "readFile") && !scr_fs_encoding_chk(ARG(1))) return NULL;
|
|
513
|
+
if (!strcmp(op, "read") && count >= 4 && !scr_fs_read_validate(ARG(0), ARG(1), ARG(2), ARG(3), ARG(4))) return NULL;
|
|
514
|
+
bool descriptor = vector || newControl || !strcmp(op, "close") || !strcmp(op, "fstat") || !strcmp(op, "fsync") || !strcmp(op, "read") || !strcmp(op, "write");
|
|
515
|
+
ScrStr *path = descriptor ? NULL : scr_fs_cb_path(ARG(0), !strcmp(op, "mkdtemp") ? "prefix" : "path");
|
|
516
|
+
if (!descriptor && !path) return NULL;
|
|
517
|
+
double fd = descriptor ? scr_fs_cb_number(ARG(0), "fd", -1) : -1;
|
|
518
|
+
if (scr_exc_pending()) { scr_str_release(path); scr_arr_release(vectors); return NULL; }
|
|
519
|
+
if (newControl && strcmp(op, "fdatasync")) {
|
|
520
|
+
const ScrDyn *value = ARG(1);
|
|
521
|
+
if (strcmp(op, "ftruncate") || value->kind != SCR_DYN_UNDEF) {
|
|
522
|
+
bool chmod = !strcmp(op, "fchmod");
|
|
523
|
+
if (chmod ? !scr_fs_mode_chk(value, "mode") : !scr_fs_int_range_chk(value, "len", -9007199254740991.0, 9007199254740991.0, ">= -9007199254740991 && <= 9007199254740991")) return NULL;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
ScrDyn *result = NULL;
|
|
527
|
+
const ScrDyn *buffer = NULL;
|
|
528
|
+
if (!strcmp(op, "readFile")) {
|
|
529
|
+
const ScrDyn *options = ARG(1);
|
|
530
|
+
if (options->kind != SCR_DYN_STR && (!scr_fs_cb_signal(options) || scr_fs_cb_refuse_option(options, "flag"))) goto done;
|
|
531
|
+
ScrDyn *encoding = options->kind == SCR_DYN_STR ? scr_dyn_retain((ScrDyn *)options) : scr_fs_cb_option(options, "encoding");
|
|
532
|
+
if (encoding) result = scr_fs_read_file_sync_dyn(path, encoding);
|
|
533
|
+
scr_dyn_release(encoding);
|
|
534
|
+
} else if (!strcmp(op, "writeFile") || !strcmp(op, "appendFile")) {
|
|
535
|
+
const ScrDyn *options = ARG(2);
|
|
536
|
+
if (options->kind != SCR_DYN_STR && !scr_fs_cb_signal(options)) goto done;
|
|
537
|
+
ScrDyn *encoding = options->kind == SCR_DYN_STR ? scr_dyn_retain((ScrDyn *)options) : scr_fs_cb_option(options, "encoding");
|
|
538
|
+
ScrStr *codec = encoding && encoding->kind == SCR_DYN_STR ? scr_str_retain(encoding->v.str) : scr_str_new("utf8", 4);
|
|
539
|
+
ScrBytes *data = encoding ? scr_buffer_from_dyn(ARG(1), codec) : NULL;
|
|
540
|
+
scr_str_release(codec);
|
|
541
|
+
scr_dyn_release(encoding);
|
|
542
|
+
if (data) {
|
|
543
|
+
ScrDyn *flag = scr_fs_cb_option(options->kind == SCR_DYN_STR ? scr_dyn_undefined() : options, "flag");
|
|
544
|
+
double mode = scr_fs_cb_option_number(options->kind == SCR_DYN_STR ? scr_dyn_undefined() : options, "mode", 0666);
|
|
545
|
+
double fd = flag ? scr_fs_cb_open(path, flag, mode, !strcmp(op, "appendFile") ? "a" : "w") : -1;
|
|
546
|
+
scr_dyn_release(flag);
|
|
547
|
+
if (fd >= 0) {
|
|
548
|
+
size_t offset = 0;
|
|
549
|
+
while (offset < data->len && !scr_exc_pending()) {
|
|
550
|
+
double written = scr_fs_write_sync(fd, data, (double)offset, (double)(data->len - offset), -1);
|
|
551
|
+
if (written <= 0) break;
|
|
552
|
+
offset += (size_t)written;
|
|
553
|
+
}
|
|
554
|
+
int saved = errno;
|
|
555
|
+
close((int)fd);
|
|
556
|
+
errno = saved;
|
|
557
|
+
}
|
|
558
|
+
scr_bytes_release(data);
|
|
559
|
+
}
|
|
560
|
+
} else if (!strcmp(op, "access")) scr_fs_access(path, scr_fs_cb_number(ARG(1), "mode", 0));
|
|
561
|
+
else if (!strcmp(op, "mkdir")) {
|
|
562
|
+
const ScrDyn *options = ARG(1);
|
|
563
|
+
double mode = options->kind == SCR_DYN_NUM ? options->v.num : scr_fs_cb_option_number(options, "mode", 0777);
|
|
564
|
+
if (scr_fs_cb_option_bool(options->kind == SCR_DYN_NUM ? scr_dyn_undefined() : options, "recursive")) scr_fs_mkdir_recursive_mode(path, mode);
|
|
565
|
+
else scr_fs_mkdir_mode(path, mode);
|
|
566
|
+
} else if (!strcmp(op, "mkdtemp")) result = scr_fs_cb_string(scr_fs_mkdtemp(path));
|
|
567
|
+
else if (!strcmp(op, "rm")) scr_fs_rm_opts_retry(path, scr_fs_cb_option_bool(ARG(1), "recursive"), scr_fs_cb_option_bool(ARG(1), "force"), scr_fs_cb_option_number(ARG(1), "maxRetries", 0), scr_fs_cb_option_number(ARG(1), "retryDelay", 100));
|
|
568
|
+
else if (!strcmp(op, "rmdir")) scr_fs_rmdir(path);
|
|
569
|
+
else if (!strcmp(op, "unlink")) scr_fs_unlink(path);
|
|
570
|
+
else if (!strcmp(op, "chmod")) scr_fs_chmod(path, scr_fs_cb_number(ARG(1), "mode", 0));
|
|
571
|
+
else if (!strcmp(op, "chown")) scr_fs_chown(path, scr_fs_cb_number(ARG(1), "uid", 0), scr_fs_cb_number(ARG(2), "gid", 0));
|
|
572
|
+
else if (!strcmp(op, "realpath")) result = scr_fs_cb_string(scr_fs_realpath(path));
|
|
573
|
+
else if (!strcmp(op, "stat") || !strcmp(op, "lstat")) result = scr_fs_cb_stats(path, -1, ARG(1), !strcmp(op, "lstat"));
|
|
574
|
+
else if (!strcmp(op, "fstat")) result = scr_fs_cb_stats(NULL, fd, ARG(1), false);
|
|
575
|
+
else if (!strcmp(op, "close")) scr_fs_close(fd);
|
|
576
|
+
else if (!strcmp(op, "fsync")) scr_fs_fsync(fd);
|
|
577
|
+
else if (!strcmp(op, "fdatasync")) scr_fs_fdatasync(fd);
|
|
578
|
+
else if (!strcmp(op, "fchmod")) scr_fs_fchmod(fd, ARG(1)->kind == SCR_DYN_STR ? (double)strtol(ARG(1)->v.str->data, NULL, 8) : ARG(1)->v.num);
|
|
579
|
+
else if (vector) {
|
|
580
|
+
double position = ARG(2)->kind == SCR_DYN_NUM ? ARG(2)->v.num : -1;
|
|
581
|
+
result = scr_dyn_new_num(!strcmp(op, "readv") ? scr_fs_readv_sync(fd, vectors, position) : scr_fs_writev_sync(fd, vectors, position));
|
|
582
|
+
scr_arr_release(vectors);
|
|
583
|
+
buffer = ARG(1);
|
|
584
|
+
}
|
|
585
|
+
else if (!strcmp(op, "open")) {
|
|
586
|
+
double opened = scr_fs_cb_open(path, ARG(1), scr_fs_cb_number(ARG(2), "mode", 0666), "r");
|
|
587
|
+
if (!scr_exc_pending()) result = scr_dyn_new_num(opened);
|
|
588
|
+
} else if (!strcmp(op, "cp")) {
|
|
589
|
+
if (scr_fs_cb_refuse_option(ARG(2), "filter") || scr_fs_cb_refuse_option(ARG(2), "dereference") || scr_fs_cb_refuse_option(ARG(2), "verbatimSymlinks") || scr_fs_cb_refuse_option(ARG(2), "errorOnExist") || scr_fs_cb_refuse_option(ARG(2), "mode")) goto done;
|
|
590
|
+
ScrStr *destination = scr_fs_cb_path(ARG(1), "dest");
|
|
591
|
+
if (destination) {
|
|
592
|
+
ScrDyn *force = scr_fs_cb_option(ARG(2), "force");
|
|
593
|
+
scr_fs_cb_copy(path, destination, scr_fs_cb_option_bool(ARG(2), "recursive"),
|
|
594
|
+
force && (force->kind == SCR_DYN_UNDEF || scr_dyn_truthy(force)), scr_fs_cb_option_bool(ARG(2), "preserveTimestamps"));
|
|
595
|
+
scr_dyn_release(force); scr_str_release(destination);
|
|
596
|
+
}
|
|
597
|
+
} else if (!strcmp(op, "glob")) {
|
|
598
|
+
#if SCR_FS_HAS_GLOB
|
|
599
|
+
if (strstr(path->data, "**") || scr_fs_cb_option_bool(ARG(1), "withFileTypes")) {
|
|
600
|
+
const char *message = "Recursive glob patterns and Dirent results have no native lowering";
|
|
601
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, strlen(message), "SC2020");
|
|
602
|
+
goto done;
|
|
603
|
+
}
|
|
604
|
+
ScrDyn *cwd = scr_fs_cb_option(ARG(1), "cwd");
|
|
605
|
+
ScrDyn *exclude = scr_fs_cb_option(ARG(1), "exclude");
|
|
606
|
+
if (exclude && exclude->kind != SCR_DYN_UNDEF) {
|
|
607
|
+
const char *message = "fs.glob exclude options have no native lowering";
|
|
608
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, strlen(message), "SC2020");
|
|
609
|
+
} else {
|
|
610
|
+
ScrStr *pattern = cwd && cwd->kind == SCR_DYN_STR ? scr_fs_cb_join(cwd->v.str, path->data) : scr_str_retain(path);
|
|
611
|
+
glob_t matches = {0};
|
|
612
|
+
int rc = glob(pattern->data, 0, NULL, &matches);
|
|
613
|
+
if (rc && rc != GLOB_NOMATCH) scr_fs_throw(rc == GLOB_NOSPACE ? ENOMEM : EIO, "glob", path);
|
|
614
|
+
else {
|
|
615
|
+
result = scr_dyn_new_arr();
|
|
616
|
+
size_t prefix = cwd && cwd->kind == SCR_DYN_STR ? cwd->v.str->len + 1 : 0;
|
|
617
|
+
for (size_t i = 0; i < matches.gl_pathc; i++) {
|
|
618
|
+
const char *name = matches.gl_pathv[i] + prefix;
|
|
619
|
+
scr_dyn_arr_push(result, scr_fs_cb_string(scr_str_new(name, strlen(name))));
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
globfree(&matches); scr_str_release(pattern);
|
|
623
|
+
}
|
|
624
|
+
scr_dyn_release(cwd); scr_dyn_release(exclude);
|
|
625
|
+
#else
|
|
626
|
+
scr_fs_throw(ENOSYS, "glob", path);
|
|
627
|
+
#endif
|
|
628
|
+
} else if (!strcmp(op, "read") || !strcmp(op, "write")) {
|
|
629
|
+
bool readOp = !strcmp(op, "read");
|
|
630
|
+
const ScrDyn *options = ARG(1);
|
|
631
|
+
ScrDyn *ownedBuffer = NULL;
|
|
632
|
+
if (readOp && !scr_dyn_bytes_is(options, SCR_BYTES_U8)) { ownedBuffer = scr_fs_cb_option(options, "buffer"); buffer = ownedBuffer; }
|
|
633
|
+
else buffer = options;
|
|
634
|
+
ScrBytes *bytes = buffer && buffer->kind == SCR_DYN_BYTES ? scr_dyn_bytes_unbox(buffer) : NULL;
|
|
635
|
+
if (!bytes) scr_dyn_arg_type_fail("buffer", "an instance of Buffer, TypedArray, or DataView", buffer ? buffer : scr_dyn_undefined());
|
|
636
|
+
else {
|
|
637
|
+
double offset = ownedBuffer ? scr_fs_cb_option_number(options, "offset", 0) : scr_fs_cb_number(ARG(2), "offset", 0);
|
|
638
|
+
double length = ownedBuffer ? scr_fs_cb_option_number(options, "length", bytes->len - offset) : scr_fs_cb_number(ARG(3), "length", bytes->len - offset);
|
|
639
|
+
double position = ownedBuffer ? scr_fs_cb_option_number(options, "position", -1) : scr_fs_cb_number(ARG(4), "position", -1);
|
|
640
|
+
if (!scr_exc_pending()) result = scr_dyn_new_num(readOp ? scr_fs_read_sync(fd, bytes, offset, length, position) : scr_fs_write_sync(fd, bytes, offset, length, position));
|
|
641
|
+
}
|
|
642
|
+
scr_bytes_release(bytes);
|
|
643
|
+
/* The completion retains the original buffer, including options.buffer. */
|
|
644
|
+
if (ownedBuffer) {
|
|
645
|
+
scr_fs_cb_schedule(callback, result, ownedBuffer);
|
|
646
|
+
scr_dyn_release(ownedBuffer); scr_str_release(path);
|
|
647
|
+
return scr_dyn_retain(scr_dyn_undefined());
|
|
648
|
+
}
|
|
649
|
+
} else if (!strcmp(op, "copyFile") || !strcmp(op, "rename") || !strcmp(op, "link") || !strcmp(op, "symlink")) {
|
|
650
|
+
ScrStr *destination = scr_fs_cb_path(ARG(1), "dest");
|
|
651
|
+
if (destination) {
|
|
652
|
+
if (!strcmp(op, "rename")) scr_fs_rename(path, destination);
|
|
653
|
+
else if (!strcmp(op, "link")) scr_fs_link(path, destination);
|
|
654
|
+
else if (!strcmp(op, "copyFile")) {
|
|
655
|
+
double flags = scr_fs_cb_number(ARG(2), "mode", 0);
|
|
656
|
+
if (flags == 1 && scr_fs_exists(destination)) scr_fs_throw(EEXIST, "copyfile", destination);
|
|
657
|
+
else if (flags != 0 && flags != 1) {
|
|
658
|
+
static const char message[] = "fs.copyFile clone flags have no native lowering";
|
|
659
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, sizeof message - 1, "SC2020");
|
|
660
|
+
} else if (!scr_exc_pending()) scr_fs_copyfile(path, destination);
|
|
661
|
+
}
|
|
662
|
+
else {
|
|
663
|
+
#if !defined(_WIN32)
|
|
664
|
+
if (symlink(path->data, destination->data) < 0) scr_fs_throw(errno, "symlink", path);
|
|
665
|
+
#else
|
|
666
|
+
scr_fs_throw(ENOSYS, "symlink", path);
|
|
667
|
+
#endif
|
|
668
|
+
}
|
|
669
|
+
scr_str_release(destination);
|
|
670
|
+
}
|
|
671
|
+
} else if (!strcmp(op, "truncate") || !strcmp(op, "ftruncate")) {
|
|
672
|
+
double length = scr_fs_cb_number(ARG(1), "len", 0);
|
|
673
|
+
if (!scr_exc_pending()) {
|
|
674
|
+
if (descriptor) scr_fs_ftruncate(fd, length);
|
|
675
|
+
else if (truncate(path->data, (off_t)length) < 0) scr_fs_throw(errno, "truncate", path);
|
|
676
|
+
}
|
|
677
|
+
} else if (!strcmp(op, "readlink")) {
|
|
678
|
+
#ifndef _WIN32
|
|
679
|
+
size_t capacity = 256;
|
|
680
|
+
char *text = NULL;
|
|
681
|
+
for (;;) {
|
|
682
|
+
char *grown = realloc(text, capacity);
|
|
683
|
+
if (!grown) scr_bytes_io_oom();
|
|
684
|
+
text = grown;
|
|
685
|
+
ssize_t size = readlink(path->data, text, capacity);
|
|
686
|
+
if (size < 0) { scr_fs_throw(errno, "readlink", path); break; }
|
|
687
|
+
if ((size_t)size < capacity) { result = scr_fs_cb_string(scr_str_new(text, (size_t)size)); break; }
|
|
688
|
+
capacity *= 2;
|
|
689
|
+
}
|
|
690
|
+
free(text);
|
|
691
|
+
#else
|
|
692
|
+
scr_fs_throw(ENOSYS, "readlink", path);
|
|
693
|
+
#endif
|
|
694
|
+
} else if (!strcmp(op, "utimes")) {
|
|
695
|
+
double access = scr_fs_to_unix_timestamp(ARG(1)), modified = scr_fs_to_unix_timestamp(ARG(2));
|
|
696
|
+
#if !defined(_WIN32)
|
|
697
|
+
struct timespec times[2] = {
|
|
698
|
+
{ (time_t)floor(access), (long)((access - floor(access)) * 1000000000) },
|
|
699
|
+
{ (time_t)floor(modified), (long)((modified - floor(modified)) * 1000000000) },
|
|
700
|
+
};
|
|
701
|
+
if (!scr_exc_pending() && utimensat(AT_FDCWD, path->data, times, 0) < 0) scr_fs_throw(errno, "utime", path);
|
|
702
|
+
#else
|
|
703
|
+
struct utimbuf times = { (time_t)access, (time_t)modified };
|
|
704
|
+
if (!scr_exc_pending() && utime(path->data, ×) < 0) scr_fs_throw(errno, "utime", path);
|
|
705
|
+
#endif
|
|
706
|
+
} else if (!strcmp(op, "readdir")) {
|
|
707
|
+
if (scr_fs_cb_refuse_option(ARG(1), "encoding") || scr_fs_cb_option_bool(ARG(1), "withFileTypes") || scr_fs_cb_option_bool(ARG(1), "recursive")) {
|
|
708
|
+
if (!scr_exc_pending()) { const char *message = "Recursive readdir and Dirent results have no native lowering"; scr_throw_error_msg_code(SCR_ERR_ERROR, message, strlen(message), "SC2020"); }
|
|
709
|
+
goto done;
|
|
710
|
+
}
|
|
711
|
+
ScrArr *names = scr_fs_readdir(path);
|
|
712
|
+
if (names) {
|
|
713
|
+
result = scr_dyn_new_arr();
|
|
714
|
+
for (size_t i = 0; i < (size_t)scr_arr_len(names); i++) scr_dyn_arr_push(result, scr_fs_cb_string(scr_arr_get_ref(names, (double)i)));
|
|
715
|
+
scr_arr_release(names);
|
|
716
|
+
}
|
|
717
|
+
} else {
|
|
718
|
+
char message[160];
|
|
719
|
+
int length = snprintf(message, sizeof message, "Native filesystem callback fs.%s with these options has no lowering", op);
|
|
720
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, (size_t)length, "SC2020");
|
|
721
|
+
}
|
|
722
|
+
#undef ARG
|
|
723
|
+
done:
|
|
724
|
+
scr_str_release(path);
|
|
725
|
+
scr_fs_cb_schedule(callback, result, buffer);
|
|
726
|
+
return scr_dyn_retain(scr_dyn_undefined());
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
static ScrDyn *scr_fs_cb_value_call(ScrClosure *closure, ScrDyn *const *args, size_t argc) {
|
|
730
|
+
ScrStr *member = scr_box_get_ref(closure->caps[0]);
|
|
731
|
+
ScrDyn *result = scr_fs_cb_invoke(member, args, argc);
|
|
732
|
+
scr_str_release(member);
|
|
733
|
+
return result;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
ScrDyn *scr_fs_callback_value(ScrStr *member) {
|
|
737
|
+
ScrClosure *closure = scr_closure_new(NULL, 1);
|
|
738
|
+
closure->caps[0] = scr_box_new(SCR_BOX_STR);
|
|
739
|
+
scr_box_set_ref(closure->caps[0], scr_str_retain(member));
|
|
740
|
+
return scr_dyn_new_func(closure, scr_fs_cb_value_call, 0, "native:fs.callback", "filesystemCallback");
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
ScrDyn *scr_fs_callback_call(ScrStr *member, const ScrDyn *args) {
|
|
744
|
+
return scr_fs_cb_invoke(member, args->v.arr.items, args->v.arr.len);
|
|
745
|
+
}
|
|
746
|
+
|
|
143
747
|
/* ── crypto.randomBytes → a real Buffer ────────────────────────────────── */
|
|
144
748
|
|
|
145
749
|
ScrBytes *scr_crypto_random_bytes(double n) {
|
|
@@ -383,6 +987,12 @@ static bool scr_fs_path_chk(const ScrDyn *p, const char *name) {
|
|
|
383
987
|
* options record's `encoding` member): Node throws ERR_INVALID_ARG_VALUE
|
|
384
988
|
* for any truthy value Buffer.isEncoding rejects. */
|
|
385
989
|
static bool scr_fs_encoding_chk(const ScrDyn *opts) {
|
|
990
|
+
if (opts->kind == SCR_DYN_TYPED_REF) {
|
|
991
|
+
ScrDyn *view = scr_dyn_typed_ref_materialize(opts);
|
|
992
|
+
bool valid = view && !scr_exc_pending() && scr_fs_encoding_chk(view);
|
|
993
|
+
scr_dyn_release(view);
|
|
994
|
+
return valid;
|
|
995
|
+
}
|
|
386
996
|
const ScrDyn *enc = opts;
|
|
387
997
|
if (opts->kind == SCR_DYN_OBJ) {
|
|
388
998
|
enc = scr_dyn_obj_get(opts, "encoding", 8);
|
|
@@ -670,15 +1280,15 @@ static bool scr_fs_int_range_chk(const ScrDyn *v, const char *name, double min,
|
|
|
670
1280
|
return true;
|
|
671
1281
|
}
|
|
672
1282
|
|
|
673
|
-
|
|
674
|
-
|
|
1283
|
+
static bool scr_fs_read_validate(const ScrDyn *fd, const ScrDyn *buffer, const ScrDyn *offset,
|
|
1284
|
+
const ScrDyn *length, const ScrDyn *position) {
|
|
675
1285
|
if (buffer->kind != SCR_DYN_BYTES) {
|
|
676
1286
|
scr_dyn_arg_type_fail("buffer", "an instance of Buffer, TypedArray, or DataView", buffer);
|
|
677
|
-
return;
|
|
1287
|
+
return false;
|
|
678
1288
|
}
|
|
679
1289
|
if (fd->kind != SCR_DYN_NUM) {
|
|
680
1290
|
scr_dyn_arg_type_fail("fd", "of type number", fd);
|
|
681
|
-
return;
|
|
1291
|
+
return false;
|
|
682
1292
|
}
|
|
683
1293
|
double buflen = scr_bytes_byte_len(buffer->v.bytes);
|
|
684
1294
|
if (!scr_fs_dyn_absent(offset)) {
|
|
@@ -686,12 +1296,12 @@ void scr_fs_read_chk(const ScrDyn *fd, const ScrDyn *buffer, const ScrDyn *offse
|
|
|
686
1296
|
* Node renders each with its own max. */
|
|
687
1297
|
if (!scr_fs_int_range_chk(offset, "offset", 0, 9007199254740991.0,
|
|
688
1298
|
">= 0 && <= 9007199254740991")) {
|
|
689
|
-
return;
|
|
1299
|
+
return false;
|
|
690
1300
|
}
|
|
691
1301
|
if (offset->v.num > buflen) {
|
|
692
1302
|
char range[64];
|
|
693
1303
|
snprintf(range, sizeof range, ">= 0 && <= %.0f", buflen);
|
|
694
|
-
if (!scr_fs_int_range_chk(offset, "offset", 0, buflen, range)) return;
|
|
1304
|
+
if (!scr_fs_int_range_chk(offset, "offset", 0, buflen, range)) return false;
|
|
695
1305
|
}
|
|
696
1306
|
}
|
|
697
1307
|
double off = offset->kind == SCR_DYN_NUM ? offset->v.num : 0;
|
|
@@ -708,10 +1318,10 @@ void scr_fs_read_chk(const ScrDyn *fd, const ScrDyn *buffer, const ScrDyn *offse
|
|
|
708
1318
|
int len = snprintf(msg, sizeof msg,
|
|
709
1319
|
"The value of \"length\" is out of range. %s Received %s", shape, recv);
|
|
710
1320
|
scr_throw_error_msg_code(SCR_ERR_RANGE, msg, (size_t)len, "ERR_OUT_OF_RANGE");
|
|
711
|
-
return;
|
|
1321
|
+
return false;
|
|
712
1322
|
}
|
|
713
1323
|
scr_dyn_arg_type_fail("length", "of type number", length);
|
|
714
|
-
return;
|
|
1324
|
+
return false;
|
|
715
1325
|
}
|
|
716
1326
|
if (length->v.num > buflen - off) {
|
|
717
1327
|
char recv[48], msg[160];
|
|
@@ -720,20 +1330,26 @@ void scr_fs_read_chk(const ScrDyn *fd, const ScrDyn *buffer, const ScrDyn *offse
|
|
|
720
1330
|
"The value of \"length\" is out of range. It must be <= %.0f. Received %s",
|
|
721
1331
|
buflen - off, recv);
|
|
722
1332
|
scr_throw_error_msg_code(SCR_ERR_RANGE, msg, (size_t)len, "ERR_OUT_OF_RANGE");
|
|
723
|
-
return;
|
|
1333
|
+
return false;
|
|
724
1334
|
}
|
|
725
1335
|
}
|
|
726
1336
|
if (!scr_fs_dyn_absent(position)) {
|
|
727
1337
|
if (position->kind != SCR_DYN_NUM) {
|
|
728
1338
|
scr_dyn_arg_type_fail("position", "of type bigint or integer", position);
|
|
729
|
-
return;
|
|
1339
|
+
return false;
|
|
730
1340
|
}
|
|
731
1341
|
if (!scr_fs_int_range_chk(position, "position", -1, 9007199254740991.0,
|
|
732
1342
|
">= -1 && <= 9007199254740991")) {
|
|
733
|
-
return;
|
|
1343
|
+
return false;
|
|
734
1344
|
}
|
|
735
1345
|
}
|
|
736
|
-
|
|
1346
|
+
return true;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
void scr_fs_read_chk(const ScrDyn *fd, const ScrDyn *buffer, const ScrDyn *offset,
|
|
1351
|
+
const ScrDyn *length, const ScrDyn *position, const ScrStr *fence) {
|
|
1352
|
+
if (scr_fs_read_validate(fd, buffer, offset, length, position)) scr_throw_lowering_fence(fence);
|
|
737
1353
|
}
|
|
738
1354
|
|
|
739
1355
|
/* createReadStream/createWriteStream(path, options?): getOptions'
|