goscript 0.0.36 → 0.0.38
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/compiler/analysis.go +129 -8
- package/compiler/compiler.go +4 -1
- package/compiler/composite-lit.go +2 -4
- package/compiler/expr-call.go +26 -0
- package/compiler/lit.go +83 -0
- package/compiler/protobuf.go +2 -2
- package/compiler/spec-value.go +3 -3
- package/compiler/spec.go +7 -4
- package/compiler/stmt-assign.go +1 -1
- package/compiler/stmt.go +26 -8
- package/dist/gs/builtin/slice.js +2 -1
- package/dist/gs/builtin/slice.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/errors.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/errors.js +182 -23
- package/dist/gs/github.com/pkg/errors/errors.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/go113.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/go113.js +1 -1
- package/dist/gs/github.com/pkg/errors/go113.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/index.d.ts +3 -3
- package/dist/gs/github.com/pkg/errors/index.js +3 -3
- package/dist/gs/github.com/pkg/errors/index.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/stack.d.ts +1 -1
- package/dist/gs/github.com/pkg/errors/stack.js +8 -5
- package/dist/gs/github.com/pkg/errors/stack.js.map +1 -1
- package/dist/gs/internal/abi/index.d.ts +20 -0
- package/dist/gs/internal/abi/index.js +20 -0
- package/dist/gs/internal/abi/index.js.map +1 -0
- package/dist/gs/internal/bytealg/index.d.ts +2 -0
- package/dist/gs/internal/bytealg/index.js +33 -0
- package/dist/gs/internal/bytealg/index.js.map +1 -0
- package/dist/gs/internal/byteorder/index.d.ts +8 -0
- package/dist/gs/internal/byteorder/index.js +34 -0
- package/dist/gs/internal/byteorder/index.js.map +1 -0
- package/dist/gs/internal/testlog/index.d.ts +1 -0
- package/dist/gs/internal/testlog/index.js +5 -0
- package/dist/gs/internal/testlog/index.js.map +1 -0
- package/dist/gs/math/index.d.ts +44 -44
- package/dist/gs/math/index.js +44 -44
- package/dist/gs/math/index.js.map +1 -1
- package/dist/gs/os/dir.gs.d.ts +6 -0
- package/dist/gs/os/dir.gs.js +35 -0
- package/dist/gs/os/dir.gs.js.map +1 -0
- package/dist/gs/os/dir_unix.gs.d.ts +7 -0
- package/dist/gs/os/dir_unix.gs.js +113 -0
- package/dist/gs/os/dir_unix.gs.js.map +1 -0
- package/dist/gs/os/dirent_js.gs.d.ts +5 -0
- package/dist/gs/os/dirent_js.gs.js +20 -0
- package/dist/gs/os/dirent_js.gs.js.map +1 -0
- package/dist/gs/os/env.gs.d.ts +12 -0
- package/dist/gs/os/env.gs.js +157 -0
- package/dist/gs/os/env.gs.js.map +1 -0
- package/dist/gs/os/error.gs.d.ts +40 -0
- package/dist/gs/os/error.gs.js +158 -0
- package/dist/gs/os/error.gs.js.map +1 -0
- package/dist/gs/os/error_errno.gs.d.ts +1 -0
- package/dist/gs/os/error_errno.gs.js +5 -0
- package/dist/gs/os/error_errno.gs.js.map +1 -0
- package/dist/gs/os/exec.gs.d.ts +60 -0
- package/dist/gs/os/exec.gs.js +136 -0
- package/dist/gs/os/exec.gs.js.map +1 -0
- package/dist/gs/os/exec_nohandle.gs.d.ts +1 -0
- package/dist/gs/os/exec_nohandle.gs.js +2 -0
- package/dist/gs/os/exec_nohandle.gs.js.map +1 -0
- package/dist/gs/os/exec_posix.gs.d.ts +25 -0
- package/dist/gs/os/exec_posix.gs.js +67 -0
- package/dist/gs/os/exec_posix.gs.js.map +1 -0
- package/dist/gs/os/exec_unix.gs.d.ts +4 -0
- package/dist/gs/os/exec_unix.gs.js +46 -0
- package/dist/gs/os/exec_unix.gs.js.map +1 -0
- package/dist/gs/os/executable.gs.d.ts +2 -0
- package/dist/gs/os/executable.gs.js +16 -0
- package/dist/gs/os/executable.gs.js.map +1 -0
- package/dist/gs/os/executable_js.gs.d.ts +2 -0
- package/dist/gs/os/executable_js.gs.js +5 -0
- package/dist/gs/os/executable_js.gs.js.map +1 -0
- package/dist/gs/os/executable_wasm.gs.d.ts +2 -0
- package/dist/gs/os/executable_wasm.gs.js +6 -0
- package/dist/gs/os/executable_wasm.gs.js.map +1 -0
- package/dist/gs/os/file_constants_js.gs.d.ts +41 -0
- package/dist/gs/os/file_constants_js.gs.js +78 -0
- package/dist/gs/os/file_constants_js.gs.js.map +1 -0
- package/dist/gs/os/file_js.gs.d.ts +22 -0
- package/dist/gs/os/file_js.gs.js +73 -0
- package/dist/gs/os/file_js.gs.js.map +1 -0
- package/dist/gs/os/file_open_unix.gs.d.ts +6 -0
- package/dist/gs/os/file_open_unix.gs.js +10 -0
- package/dist/gs/os/file_open_unix.gs.js.map +1 -0
- package/dist/gs/os/file_posix_js.gs.d.ts +8 -0
- package/dist/gs/os/file_posix_js.gs.js +32 -0
- package/dist/gs/os/file_posix_js.gs.js.map +1 -0
- package/dist/gs/os/file_unix_js.gs.d.ts +27 -0
- package/dist/gs/os/file_unix_js.gs.js +64 -0
- package/dist/gs/os/file_unix_js.gs.js.map +1 -0
- package/dist/gs/os/getwd_js.gs.d.ts +6 -0
- package/dist/gs/os/getwd_js.gs.js +21 -0
- package/dist/gs/os/getwd_js.gs.js.map +1 -0
- package/dist/gs/os/index.d.ts +19 -0
- package/dist/gs/os/index.js +20 -0
- package/dist/gs/os/index.js.map +1 -0
- package/dist/gs/os/path.gs.d.ts +4 -0
- package/dist/gs/os/path.gs.js +32 -0
- package/dist/gs/os/path.gs.js.map +1 -0
- package/dist/gs/os/path_unix.gs.d.ts +4 -0
- package/dist/gs/os/path_unix.gs.js +40 -0
- package/dist/gs/os/path_unix.gs.js.map +1 -0
- package/dist/gs/os/pidfd_js.gs.d.ts +6 -0
- package/dist/gs/os/pidfd_js.gs.js +14 -0
- package/dist/gs/os/pidfd_js.gs.js.map +1 -0
- package/dist/gs/os/pipe_wasm.gs.d.ts +2 -0
- package/dist/gs/os/pipe_wasm.gs.js +14 -0
- package/dist/gs/os/pipe_wasm.gs.js.map +1 -0
- package/dist/gs/os/proc.gs.d.ts +11 -0
- package/dist/gs/os/proc.gs.js +68 -0
- package/dist/gs/os/proc.gs.js.map +1 -0
- package/dist/gs/os/proc_js.gs.d.ts +3 -0
- package/dist/gs/os/proc_js.gs.js +12 -0
- package/dist/gs/os/proc_js.gs.js.map +1 -0
- package/dist/gs/os/rawconn_js.gs.d.ts +10 -0
- package/dist/gs/os/rawconn_js.gs.js +26 -0
- package/dist/gs/os/rawconn_js.gs.js.map +1 -0
- package/dist/gs/os/removeall_js.gs.d.ts +2 -0
- package/dist/gs/os/removeall_js.gs.js +7 -0
- package/dist/gs/os/removeall_js.gs.js.map +1 -0
- package/dist/gs/os/root_js.gs.d.ts +23 -0
- package/dist/gs/os/root_js.gs.js +80 -0
- package/dist/gs/os/root_js.gs.js.map +1 -0
- package/dist/gs/os/root_nonwindows.gs.d.ts +2 -0
- package/dist/gs/os/root_nonwindows.gs.js +4 -0
- package/dist/gs/os/root_nonwindows.gs.js.map +1 -0
- package/dist/gs/os/root_noopenat.gs.d.ts +11 -0
- package/dist/gs/os/root_noopenat.gs.js +31 -0
- package/dist/gs/os/root_noopenat.gs.js.map +1 -0
- package/dist/gs/os/stat.gs.d.ts +24 -0
- package/dist/gs/os/stat.gs.js +20 -0
- package/dist/gs/os/stat.gs.js.map +1 -0
- package/dist/gs/os/stat_js.gs.d.ts +6 -0
- package/dist/gs/os/stat_js.gs.js +23 -0
- package/dist/gs/os/stat_js.gs.js.map +1 -0
- package/dist/gs/os/stat_unix_js.gs.d.ts +8 -0
- package/dist/gs/os/stat_unix_js.gs.js +16 -0
- package/dist/gs/os/stat_unix_js.gs.js.map +1 -0
- package/dist/gs/os/sticky_bsd.gs.d.ts +1 -0
- package/dist/gs/os/sticky_bsd.gs.js +3 -0
- package/dist/gs/os/sticky_bsd.gs.js.map +1 -0
- package/dist/gs/os/sys.gs.d.ts +2 -0
- package/dist/gs/os/sys.gs.js +10 -0
- package/dist/gs/os/sys.gs.js.map +1 -0
- package/dist/gs/os/sys_bsd.gs.d.ts +2 -0
- package/dist/gs/os/sys_bsd.gs.js +15 -0
- package/dist/gs/os/sys_bsd.gs.js.map +1 -0
- package/dist/gs/os/sys_js.gs.d.ts +2 -0
- package/dist/gs/os/sys_js.gs.js +6 -0
- package/dist/gs/os/sys_js.gs.js.map +1 -0
- package/dist/gs/os/tempfile.gs.d.ts +5 -0
- package/dist/gs/os/tempfile.gs.js +30 -0
- package/dist/gs/os/tempfile.gs.js.map +1 -0
- package/dist/gs/os/types.gs.d.ts +59 -0
- package/dist/gs/os/types.gs.js +123 -0
- package/dist/gs/os/types.gs.js.map +1 -0
- package/dist/gs/os/types_js.gs.d.ts +74 -0
- package/dist/gs/os/types_js.gs.js +147 -0
- package/dist/gs/os/types_js.gs.js.map +1 -0
- package/dist/gs/os/types_unix.gs.d.ts +40 -0
- package/dist/gs/os/types_unix.gs.js +87 -0
- package/dist/gs/os/types_unix.gs.js.map +1 -0
- package/dist/gs/os/wait_unimp.gs.d.ts +1 -0
- package/dist/gs/os/wait_unimp.gs.js +2 -0
- package/dist/gs/os/wait_unimp.gs.js.map +1 -0
- package/dist/gs/os/zero_copy_posix.gs.d.ts +4 -0
- package/dist/gs/os/zero_copy_posix.gs.js +27 -0
- package/dist/gs/os/zero_copy_posix.gs.js.map +1 -0
- package/dist/gs/os/zero_copy_stub.gs.d.ts +1 -0
- package/dist/gs/os/zero_copy_stub.gs.js +2 -0
- package/dist/gs/os/zero_copy_stub.gs.js.map +1 -0
- package/dist/gs/reflect/abi.d.ts +59 -0
- package/dist/gs/reflect/abi.gs.d.ts +59 -0
- package/dist/gs/reflect/abi.gs.js +79 -0
- package/dist/gs/reflect/abi.gs.js.map +1 -0
- package/dist/gs/reflect/abi.js +79 -0
- package/dist/gs/reflect/abi.js.map +1 -0
- package/dist/gs/reflect/badlinkname.d.ts +52 -0
- package/dist/gs/reflect/badlinkname.gs.d.ts +52 -0
- package/dist/gs/reflect/badlinkname.gs.js +72 -0
- package/dist/gs/reflect/badlinkname.gs.js.map +1 -0
- package/dist/gs/reflect/badlinkname.js +72 -0
- package/dist/gs/reflect/badlinkname.js.map +1 -0
- package/dist/gs/reflect/deepequal.d.ts +1 -0
- package/dist/gs/reflect/deepequal.gs.d.ts +25 -0
- package/dist/gs/reflect/deepequal.gs.js +308 -0
- package/dist/gs/reflect/deepequal.gs.js.map +1 -0
- package/dist/gs/reflect/deepequal.js +139 -0
- package/dist/gs/reflect/deepequal.js.map +1 -0
- package/dist/gs/reflect/float32reg_generic.gs.d.ts +2 -0
- package/dist/gs/reflect/float32reg_generic.gs.js +10 -0
- package/dist/gs/reflect/float32reg_generic.gs.js.map +1 -0
- package/dist/gs/reflect/index.d.ts +8 -0
- package/dist/gs/reflect/index.gs.d.ts +1 -0
- package/dist/gs/reflect/index.gs.js +3 -0
- package/dist/gs/reflect/index.gs.js.map +1 -0
- package/dist/gs/reflect/index.js +10 -0
- package/dist/gs/reflect/index.js.map +1 -0
- package/dist/gs/reflect/iter.d.ts +4 -0
- package/dist/gs/reflect/iter.gs.d.ts +3 -0
- package/dist/gs/reflect/iter.gs.js +24 -0
- package/dist/gs/reflect/iter.gs.js.map +1 -0
- package/dist/gs/reflect/iter.js +24 -0
- package/dist/gs/reflect/iter.js.map +1 -0
- package/dist/gs/reflect/makefunc.gs.d.ts +34 -0
- package/dist/gs/reflect/makefunc.gs.js +288 -0
- package/dist/gs/reflect/makefunc.gs.js.map +1 -0
- package/dist/gs/reflect/map.d.ts +14 -0
- package/dist/gs/reflect/map.js +70 -0
- package/dist/gs/reflect/map.js.map +1 -0
- package/dist/gs/reflect/map_swiss.gs.d.ts +14 -0
- package/dist/gs/reflect/map_swiss.gs.js +70 -0
- package/dist/gs/reflect/map_swiss.gs.js.map +1 -0
- package/dist/gs/reflect/reflect.gs.d.ts +132 -0
- package/dist/gs/reflect/reflect.gs.js +437 -0
- package/dist/gs/reflect/reflect.gs.js.map +1 -0
- package/dist/gs/reflect/swapper.d.ts +2 -0
- package/dist/gs/reflect/swapper.gs.d.ts +1 -0
- package/dist/gs/reflect/swapper.gs.js +32 -0
- package/dist/gs/reflect/swapper.gs.js.map +1 -0
- package/dist/gs/reflect/swapper.js +46 -0
- package/dist/gs/reflect/swapper.js.map +1 -0
- package/dist/gs/reflect/type.d.ts +126 -0
- package/dist/gs/reflect/type.gs.d.ts +4 -0
- package/dist/gs/reflect/type.gs.js +21 -0
- package/dist/gs/reflect/type.gs.js.map +1 -0
- package/dist/gs/reflect/type.js +825 -0
- package/dist/gs/reflect/type.js.map +1 -0
- package/dist/gs/reflect/types.d.ts +90 -0
- package/dist/gs/reflect/types.js +119 -0
- package/dist/gs/reflect/types.js.map +1 -0
- package/dist/gs/reflect/value.d.ts +13 -0
- package/dist/gs/reflect/value.gs.d.ts +4 -0
- package/dist/gs/reflect/value.gs.js +12 -0
- package/dist/gs/reflect/value.gs.js.map +1 -0
- package/dist/gs/reflect/value.js +201 -0
- package/dist/gs/reflect/value.js.map +1 -0
- package/dist/gs/reflect/visiblefields.d.ts +4 -0
- package/dist/gs/reflect/visiblefields.gs.d.ts +3 -0
- package/dist/gs/reflect/visiblefields.gs.js +123 -0
- package/dist/gs/reflect/visiblefields.gs.js.map +1 -0
- package/dist/gs/reflect/visiblefields.js +143 -0
- package/dist/gs/reflect/visiblefields.js.map +1 -0
- package/dist/gs/strconv/index.d.ts +6 -6
- package/dist/gs/strconv/index.js +6 -6
- package/dist/gs/strconv/index.js.map +1 -1
- package/dist/gs/strings/index.d.ts +1 -1
- package/dist/gs/strings/index.js +1 -1
- package/dist/gs/strings/index.js.map +1 -1
- package/dist/gs/strings/replace.js.map +1 -1
- package/dist/gs/sync/atomic/index.d.ts +4 -4
- package/dist/gs/sync/atomic/index.js +4 -4
- package/dist/gs/sync/atomic/index.js.map +1 -1
- package/dist/gs/syscall/index.d.ts +80 -0
- package/dist/gs/syscall/index.js +169 -0
- package/dist/gs/syscall/index.js.map +1 -0
- package/dist/gs/unsafe/unsafe.js.map +1 -1
- package/gs/builtin/slice.ts +2 -1
- package/gs/github.com/pkg/errors/errors.ts +408 -238
- package/gs/github.com/pkg/errors/go113.ts +5 -6
- package/gs/github.com/pkg/errors/index.ts +12 -3
- package/gs/github.com/pkg/errors/stack.ts +107 -105
- package/gs/internal/abi/index.ts +37 -0
- package/gs/internal/bytealg/index.ts +34 -0
- package/gs/internal/byteorder/index.ts +40 -0
- package/gs/math/abs.gs.test.ts +1 -1
- package/gs/math/acosh.gs.test.ts +4 -2
- package/gs/math/asin.gs.test.ts +1 -1
- package/gs/math/asinh.gs.test.ts +7 -3
- package/gs/math/atan.gs.test.ts +1 -1
- package/gs/math/atan2.gs.test.ts +17 -9
- package/gs/math/atanh.gs.test.ts +1 -1
- package/gs/math/bits.gs.test.ts +1 -1
- package/gs/math/cbrt.gs.test.ts +1 -1
- package/gs/math/const.gs.test.ts +34 -8
- package/gs/math/copysign.gs.test.ts +7 -3
- package/gs/math/dim.gs.test.ts +19 -7
- package/gs/math/erf.gs.test.ts +1 -1
- package/gs/math/erfinv.gs.test.ts +4 -2
- package/gs/math/exp.gs.test.ts +1 -1
- package/gs/math/expm1.gs.test.ts +6 -4
- package/gs/math/floor.gs.test.ts +17 -4
- package/gs/math/fma.gs.test.ts +53 -53
- package/gs/math/frexp.gs.test.ts +112 -117
- package/gs/math/gamma.gs.test.ts +1 -1
- package/gs/math/hypot.gs.test.ts +53 -53
- package/gs/math/index.ts +80 -44
- package/gs/math/j0.gs.test.ts +6 -2
- package/gs/math/j1.gs.test.ts +6 -2
- package/gs/math/jn.gs.test.ts +9 -5
- package/gs/math/ldexp.gs.test.ts +103 -86
- package/gs/math/lgamma.gs.test.ts +10 -10
- package/gs/math/log.gs.test.ts +1 -1
- package/gs/math/log10.gs.test.ts +1 -1
- package/gs/math/log1p.gs.test.ts +2 -2
- package/gs/math/logb.gs.test.ts +1 -1
- package/gs/math/mod.gs.test.ts +2 -2
- package/gs/math/modf.gs.test.ts +7 -7
- package/gs/math/nextafter.gs.test.ts +9 -7
- package/gs/math/pow.gs.test.ts +6 -4
- package/gs/math/pow10.gs.test.ts +1 -1
- package/gs/math/remainder.gs.test.ts +1 -1
- package/gs/math/signbit.gs.test.ts +1 -1
- package/gs/math/sin.gs.test.ts +1 -1
- package/gs/math/sincos.gs.test.ts +33 -14
- package/gs/math/sinh.gs.test.ts +1 -1
- package/gs/math/sqrt.gs.test.ts +1 -1
- package/gs/math/tan.gs.test.ts +3 -3
- package/gs/math/tanh.gs.test.ts +1 -1
- package/gs/os/dir.gs.ts +42 -0
- package/gs/os/dir_unix.gs.ts +155 -0
- package/gs/os/dirent_js.gs.ts +27 -0
- package/gs/os/env.gs.ts +179 -0
- package/gs/os/error.gs.ts +205 -0
- package/gs/os/error_errno.gs.ts +12 -0
- package/gs/os/exec.gs.ts +198 -0
- package/gs/os/exec_nohandle.gs.ts +2 -0
- package/gs/os/exec_posix.gs.ts +95 -0
- package/gs/os/exec_unix.gs.ts +64 -0
- package/gs/os/executable.gs.ts +18 -0
- package/gs/os/executable_js.gs.ts +6 -0
- package/gs/os/executable_wasm.gs.ts +10 -0
- package/gs/os/file_constants_js.gs.ts +98 -0
- package/gs/os/file_js.gs.ts +99 -0
- package/gs/os/file_open_unix.gs.ts +15 -0
- package/gs/os/file_posix_js.gs.ts +40 -0
- package/gs/os/file_unix_js.gs.ts +94 -0
- package/gs/os/getwd_js.gs.ts +28 -0
- package/gs/os/index.ts +128 -0
- package/gs/os/path.gs.ts +35 -0
- package/gs/os/path_unix.gs.ts +49 -0
- package/gs/os/pidfd_js.gs.ts +25 -0
- package/gs/os/pipe_wasm.gs.ts +17 -0
- package/gs/os/proc.gs.ts +84 -0
- package/gs/os/proc_js.gs.ts +15 -0
- package/gs/os/rawconn_js.gs.ts +30 -0
- package/gs/os/removeall_js.gs.ts +9 -0
- package/gs/os/root_js.gs.ts +111 -0
- package/gs/os/root_nonwindows.gs.ts +6 -0
- package/gs/os/root_noopenat.gs.ts +45 -0
- package/gs/os/stat.gs.ts +38 -0
- package/gs/os/stat_js.gs.ts +30 -0
- package/gs/os/stat_unix_js.gs.ts +27 -0
- package/gs/os/sticky_bsd.gs.ts +4 -0
- package/gs/os/sys.gs.ts +12 -0
- package/gs/os/sys_bsd.gs.ts +17 -0
- package/gs/os/sys_js.gs.ts +9 -0
- package/gs/os/tempfile.gs.ts +34 -0
- package/gs/os/types.gs.ts +170 -0
- package/gs/os/types_js.gs.ts +205 -0
- package/gs/os/types_unix.gs.ts +118 -0
- package/gs/os/wait_unimp.gs.ts +2 -0
- package/gs/os/zero_copy_posix.gs.ts +35 -0
- package/gs/os/zero_copy_stub.gs.ts +4 -0
- package/gs/reflect/ANALYSIS.md +278 -0
- package/gs/reflect/deepequal.ts +154 -0
- package/gs/reflect/function-types.test.ts +146 -0
- package/gs/reflect/godoc.txt +67 -0
- package/gs/reflect/index.ts +83 -0
- package/gs/reflect/iter.ts +44 -0
- package/gs/reflect/map.ts +81 -0
- package/gs/reflect/swapper.ts +52 -0
- package/gs/reflect/type.ts +1012 -0
- package/gs/reflect/types.ts +214 -0
- package/gs/reflect/value.ts +264 -0
- package/gs/reflect/visiblefields.ts +173 -0
- package/gs/strconv/index.ts +39 -6
- package/gs/strings/index.ts +7 -1
- package/gs/strings/replace.ts +1 -9
- package/gs/sync/atomic/index.ts +53 -4
- package/gs/syscall/index.ts +212 -0
- package/gs/unsafe/unsafe.ts +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
// JavaScript-specific stubs for file constants and operations
|
|
5
|
+
// These provide the required constants and stub implementations
|
|
6
|
+
|
|
7
|
+
// File open flags - using values compatible with typical Unix systems
|
|
8
|
+
export const O_RDONLY = 0
|
|
9
|
+
export const O_WRONLY = 1
|
|
10
|
+
export const O_RDWR = 2
|
|
11
|
+
export const O_APPEND = 1024
|
|
12
|
+
export const O_CREATE = 64
|
|
13
|
+
export const O_EXCL = 128
|
|
14
|
+
export const O_SYNC = 1052672
|
|
15
|
+
export const O_TRUNC = 512
|
|
16
|
+
|
|
17
|
+
// Seek constants
|
|
18
|
+
export const SEEK_SET = 0
|
|
19
|
+
export const SEEK_CUR = 1
|
|
20
|
+
export const SEEK_END = 2
|
|
21
|
+
|
|
22
|
+
// LinkError stub for compatibility
|
|
23
|
+
export class LinkError {
|
|
24
|
+
public get Op(): string {
|
|
25
|
+
return this._fields.Op.value
|
|
26
|
+
}
|
|
27
|
+
public set Op(value: string) {
|
|
28
|
+
this._fields.Op.value = value
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public get Old(): string {
|
|
32
|
+
return this._fields.Old.value
|
|
33
|
+
}
|
|
34
|
+
public set Old(value: string) {
|
|
35
|
+
this._fields.Old.value = value
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public get New(): string {
|
|
39
|
+
return this._fields.New.value
|
|
40
|
+
}
|
|
41
|
+
public set New(value: string) {
|
|
42
|
+
this._fields.New.value = value
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public get Err(): $.GoError {
|
|
46
|
+
return this._fields.Err.value
|
|
47
|
+
}
|
|
48
|
+
public set Err(value: $.GoError) {
|
|
49
|
+
this._fields.Err.value = value
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public _fields: {
|
|
53
|
+
Op: $.VarRef<string>;
|
|
54
|
+
Old: $.VarRef<string>;
|
|
55
|
+
New: $.VarRef<string>;
|
|
56
|
+
Err: $.VarRef<$.GoError>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
constructor(init?: Partial<{Op?: string, Old?: string, New?: string, Err?: $.GoError}>) {
|
|
60
|
+
this._fields = {
|
|
61
|
+
Op: $.varRef(init?.Op ?? ""),
|
|
62
|
+
Old: $.varRef(init?.Old ?? ""),
|
|
63
|
+
New: $.varRef(init?.New ?? ""),
|
|
64
|
+
Err: $.varRef(init?.Err ?? null)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public Error(): string {
|
|
69
|
+
const e = this
|
|
70
|
+
return e.Op + " " + e.Old + " " + e.New + ": " + (e.Err?.Error() ?? "")
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public Unwrap(): $.GoError {
|
|
74
|
+
const e = this
|
|
75
|
+
return e.Err
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Directory and file operation stubs
|
|
80
|
+
export function Readlink(name: string): [string, $.GoError] {
|
|
81
|
+
return ["", ErrUnimplemented]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function TempDir(): string {
|
|
85
|
+
return "/tmp"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function UserCacheDir(): [string, $.GoError] {
|
|
89
|
+
return ["", ErrUnimplemented]
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function UserConfigDir(): [string, $.GoError] {
|
|
93
|
+
return ["", ErrUnimplemented]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function UserHomeDir(): [string, $.GoError] {
|
|
97
|
+
return ["", ErrUnimplemented]
|
|
98
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
import { File } from "./types_js.gs.js";
|
|
4
|
+
|
|
5
|
+
import * as fs from "@goscript/io/fs/index.js"
|
|
6
|
+
|
|
7
|
+
// JavaScript-specific implementations for filesystem operations
|
|
8
|
+
// These functions stub filesystem operations that cannot be implemented
|
|
9
|
+
// in a JavaScript environment
|
|
10
|
+
|
|
11
|
+
// File operations - stub implementations
|
|
12
|
+
export function Open(name: string): [File | null, $.GoError] {
|
|
13
|
+
return [null, ErrUnimplemented]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function Create(name: string): [File | null, $.GoError] {
|
|
17
|
+
return [null, ErrUnimplemented]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function OpenFile(name: string, flag: number, perm: number): [File | null, $.GoError] {
|
|
21
|
+
return [null, ErrUnimplemented]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function ReadFile(name: string): [$.Bytes, $.GoError] {
|
|
25
|
+
return [null, ErrUnimplemented]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function WriteFile(name: string, data: $.Bytes, perm: number): $.GoError {
|
|
29
|
+
return ErrUnimplemented
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Directory operations - stub implementations
|
|
33
|
+
export function Mkdir(name: string, perm: number): $.GoError {
|
|
34
|
+
return ErrUnimplemented
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function MkdirAll(path: string, perm: number): $.GoError {
|
|
38
|
+
return ErrUnimplemented
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function Remove(name: string): $.GoError {
|
|
42
|
+
return ErrUnimplemented
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function RemoveAll(path: string): $.GoError {
|
|
46
|
+
return ErrUnimplemented
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function Chdir(dir: string): $.GoError {
|
|
50
|
+
return ErrUnimplemented
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function Chmod(name: string, mode: number): $.GoError {
|
|
54
|
+
return ErrUnimplemented
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function Rename(oldpath: string, newpath: string): $.GoError {
|
|
58
|
+
return ErrUnimplemented
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// File information operations - stub implementations
|
|
62
|
+
export function Stat(name: string): [fs.FileInfo, $.GoError] {
|
|
63
|
+
return [null, ErrUnimplemented]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function Lstat(name: string): [fs.FileInfo, $.GoError] {
|
|
67
|
+
return [null, ErrUnimplemented]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Link operations - stub implementations
|
|
71
|
+
export function Link(oldname: string, newname: string): $.GoError {
|
|
72
|
+
return ErrUnimplemented
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function Symlink(oldname: string, newname: string): $.GoError {
|
|
76
|
+
return ErrUnimplemented
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function Readlink(name: string): [string, $.GoError] {
|
|
80
|
+
return ["", ErrUnimplemented]
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function Truncate(name: string, size: number): $.GoError {
|
|
84
|
+
return ErrUnimplemented
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// File system information - stub implementations
|
|
88
|
+
export function DirFS(dir: string): fs.FS {
|
|
89
|
+
// Return a stub filesystem that always returns ErrUnimplemented
|
|
90
|
+
return new stubFS()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
class stubFS {
|
|
94
|
+
public Open(name: string): [fs.File, $.GoError] {
|
|
95
|
+
return [null, ErrUnimplemented]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
import * as syscall from "@goscript/syscall/index.js"
|
|
5
|
+
|
|
6
|
+
// Stub SysFile for JavaScript environment
|
|
7
|
+
class SysFile {
|
|
8
|
+
constructor(init?: any) {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function open(path: string, flag: number, perm: number): [number, SysFile, $.GoError] {
|
|
12
|
+
let [fd, err] = syscall.Open(path, flag, perm)
|
|
13
|
+
return [fd, new SysFile({}), err]
|
|
14
|
+
}
|
|
15
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
// JavaScript-specific stubs for POSIX file operations
|
|
5
|
+
// These operations are not available in JavaScript environments
|
|
6
|
+
|
|
7
|
+
// syscallMode stub
|
|
8
|
+
export function syscallMode(i: number): number {
|
|
9
|
+
return 0
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// ignoringEINTR stub
|
|
13
|
+
export function ignoringEINTR(fn: () => $.GoError): $.GoError {
|
|
14
|
+
return ErrUnimplemented
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ignoringEINTR2 stub
|
|
18
|
+
export function ignoringEINTR2(fn: () => [string, $.GoError]): [string, $.GoError] {
|
|
19
|
+
return ["", ErrUnimplemented]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Chmod operation stub
|
|
23
|
+
export function Chmod(name: string, mode: number): $.GoError {
|
|
24
|
+
return ErrUnimplemented
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Chown operation stub
|
|
28
|
+
export function Chown(name: string, uid: number, gid: number): $.GoError {
|
|
29
|
+
return ErrUnimplemented
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Lchown operation stub
|
|
33
|
+
export function Lchown(name: string, uid: number, gid: number): $.GoError {
|
|
34
|
+
return ErrUnimplemented
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Chtimes operation stub
|
|
38
|
+
export function Chtimes(name: string, atime: any, mtime: any): $.GoError {
|
|
39
|
+
return ErrUnimplemented
|
|
40
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
import { File } from "./types_js.gs.js";
|
|
4
|
+
|
|
5
|
+
import * as fs from "@goscript/io/fs/index.js"
|
|
6
|
+
|
|
7
|
+
// JavaScript-specific implementations for Unix file operations
|
|
8
|
+
// These functions stub Unix-specific operations that cannot be implemented in JavaScript
|
|
9
|
+
|
|
10
|
+
// Device null path - stub for JavaScript
|
|
11
|
+
export const DevNull = "/dev/null"
|
|
12
|
+
|
|
13
|
+
// Stdin, Stdout, Stderr - stub implementations
|
|
14
|
+
export const Stdin: File | null = null
|
|
15
|
+
export const Stdout: File | null = null
|
|
16
|
+
export const Stderr: File | null = null
|
|
17
|
+
|
|
18
|
+
// NewFile creates a File from a file descriptor - stub implementation
|
|
19
|
+
export function NewFile(fd: number, name: string): File | null {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// File operations that need to be stubbed
|
|
24
|
+
export function Remove(name: string): $.GoError {
|
|
25
|
+
return ErrUnimplemented
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function Link(oldname: string, newname: string): $.GoError {
|
|
29
|
+
return ErrUnimplemented
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function Symlink(oldname: string, newname: string): $.GoError {
|
|
33
|
+
return ErrUnimplemented
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function Truncate(name: string, size: number): $.GoError {
|
|
37
|
+
return ErrUnimplemented
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Internal stub functions that may be referenced by other files
|
|
41
|
+
export function rename(oldname: string, newname: string): $.GoError {
|
|
42
|
+
return ErrUnimplemented
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function openFileNolog(name: string, flag: number, perm: number): [File | null, $.GoError] {
|
|
46
|
+
return [null, ErrUnimplemented]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function openDirNolog(name: string): [File | null, $.GoError] {
|
|
50
|
+
return [null, ErrUnimplemented]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function tempDir(): string {
|
|
54
|
+
return "/tmp"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function readlink(name: string): [string, $.GoError] {
|
|
58
|
+
return ["", ErrUnimplemented]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// File class methods that need to be stubbed for unix compatibility
|
|
62
|
+
export function fixLongPath(path: string): string {
|
|
63
|
+
return path
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function sigpipe(): void {
|
|
67
|
+
// No-op in JavaScript
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function epipecheck(file: File | null, e: $.GoError): void {
|
|
71
|
+
// No-op in JavaScript
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// dirInfo stub for compatibility
|
|
75
|
+
export interface dirInfo {
|
|
76
|
+
close(): void
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Network file creation stub
|
|
80
|
+
export function net_newUnixFile(fd: number, name: string): File | null {
|
|
81
|
+
return null
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// File kind enum for compatibility
|
|
85
|
+
export type newFileKind = number
|
|
86
|
+
|
|
87
|
+
export function newFile(fd: number, name: string, kind: newFileKind, nonBlocking: boolean): File | null {
|
|
88
|
+
return null
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Directory entry stubs
|
|
92
|
+
export function newUnixDirent(parent: string, name: string, typ: number): [fs.DirEntry | null, $.GoError] {
|
|
93
|
+
return [null, ErrUnimplemented]
|
|
94
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
|
|
3
|
+
import * as fs from "@goscript/io/fs/index.js"
|
|
4
|
+
|
|
5
|
+
// JavaScript-specific implementation of Getwd
|
|
6
|
+
// Working directories are not a concept in JavaScript environments
|
|
7
|
+
// Store working directory in a global variable
|
|
8
|
+
|
|
9
|
+
// Global working directory variable, defaults to test directory
|
|
10
|
+
let currentWorkingDir: string = "/"
|
|
11
|
+
|
|
12
|
+
export function Getwd(): [string, $.GoError] {
|
|
13
|
+
return [currentWorkingDir, null]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Set the working directory (for internal use)
|
|
17
|
+
export function setWorkingDir(dir: string): void {
|
|
18
|
+
currentWorkingDir = dir
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Additional functions that may be imported by other files
|
|
22
|
+
export function statNolog(name: string): [fs.FileInfo | null, $.GoError] {
|
|
23
|
+
return [null, fs.ErrNotExist]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function lstatNolog(name: string): [fs.FileInfo | null, $.GoError] {
|
|
27
|
+
return [null, fs.ErrNotExist]
|
|
28
|
+
}
|
package/gs/os/index.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export { CopyFS, ReadDir } from './dir.gs.js'
|
|
2
|
+
export {
|
|
3
|
+
Clearenv,
|
|
4
|
+
Environ,
|
|
5
|
+
Expand,
|
|
6
|
+
ExpandEnv,
|
|
7
|
+
Getenv,
|
|
8
|
+
LookupEnv,
|
|
9
|
+
Setenv,
|
|
10
|
+
Unsetenv,
|
|
11
|
+
} from './env.gs.js'
|
|
12
|
+
export {
|
|
13
|
+
ErrClosed,
|
|
14
|
+
ErrDeadlineExceeded,
|
|
15
|
+
ErrExist,
|
|
16
|
+
ErrInvalid,
|
|
17
|
+
ErrNoDeadline,
|
|
18
|
+
ErrNotExist,
|
|
19
|
+
ErrPermission,
|
|
20
|
+
ErrUnimplemented,
|
|
21
|
+
IsExist,
|
|
22
|
+
IsNotExist,
|
|
23
|
+
IsPermission,
|
|
24
|
+
IsTimeout,
|
|
25
|
+
NewSyscallError,
|
|
26
|
+
PathError,
|
|
27
|
+
SyscallError,
|
|
28
|
+
} from './error.gs.js'
|
|
29
|
+
export {
|
|
30
|
+
ErrProcessDone,
|
|
31
|
+
FindProcess,
|
|
32
|
+
Getpid,
|
|
33
|
+
Getppid,
|
|
34
|
+
ProcAttr,
|
|
35
|
+
Process,
|
|
36
|
+
Signal,
|
|
37
|
+
StartProcess,
|
|
38
|
+
} from './exec.gs.js'
|
|
39
|
+
export { Interrupt, Kill, ProcessState } from './exec_posix.gs.js'
|
|
40
|
+
export { Executable } from './executable.gs.js'
|
|
41
|
+
export {
|
|
42
|
+
Chdir,
|
|
43
|
+
Chmod,
|
|
44
|
+
Create,
|
|
45
|
+
DirFS,
|
|
46
|
+
Mkdir,
|
|
47
|
+
Open,
|
|
48
|
+
OpenFile,
|
|
49
|
+
ReadFile,
|
|
50
|
+
Rename,
|
|
51
|
+
WriteFile,
|
|
52
|
+
MkdirAll,
|
|
53
|
+
RemoveAll,
|
|
54
|
+
} from './file_js.gs.js'
|
|
55
|
+
export {
|
|
56
|
+
LinkError,
|
|
57
|
+
O_APPEND,
|
|
58
|
+
O_CREATE,
|
|
59
|
+
O_EXCL,
|
|
60
|
+
O_RDONLY,
|
|
61
|
+
O_RDWR,
|
|
62
|
+
O_SYNC,
|
|
63
|
+
O_TRUNC,
|
|
64
|
+
O_WRONLY,
|
|
65
|
+
Readlink,
|
|
66
|
+
SEEK_CUR,
|
|
67
|
+
SEEK_END,
|
|
68
|
+
SEEK_SET,
|
|
69
|
+
TempDir,
|
|
70
|
+
UserCacheDir,
|
|
71
|
+
UserConfigDir,
|
|
72
|
+
UserHomeDir,
|
|
73
|
+
} from './file_constants_js.gs.js'
|
|
74
|
+
export {
|
|
75
|
+
DevNull,
|
|
76
|
+
Link,
|
|
77
|
+
NewFile,
|
|
78
|
+
Remove,
|
|
79
|
+
Stderr,
|
|
80
|
+
Stdin,
|
|
81
|
+
Stdout,
|
|
82
|
+
Symlink,
|
|
83
|
+
Truncate,
|
|
84
|
+
} from './file_unix_js.gs.js'
|
|
85
|
+
export { Chown, Chtimes, Lchown } from './file_posix_js.gs.js'
|
|
86
|
+
export { Getwd } from './getwd_js.gs.js'
|
|
87
|
+
export {
|
|
88
|
+
IsPathSeparator,
|
|
89
|
+
PathListSeparator,
|
|
90
|
+
PathSeparator,
|
|
91
|
+
} from './path_unix.gs.js'
|
|
92
|
+
export { Pipe } from './pipe_wasm.gs.js'
|
|
93
|
+
export {
|
|
94
|
+
Args,
|
|
95
|
+
Exit,
|
|
96
|
+
Getegid,
|
|
97
|
+
Geteuid,
|
|
98
|
+
Getgid,
|
|
99
|
+
Getgroups,
|
|
100
|
+
Getuid,
|
|
101
|
+
} from './proc.gs.js'
|
|
102
|
+
export { OpenInRoot, OpenRoot, Root } from './root_js.gs.js'
|
|
103
|
+
export { Lstat, Stat } from './stat_js.gs.js'
|
|
104
|
+
export { Hostname } from './sys.gs.js'
|
|
105
|
+
export { CreateTemp, MkdirTemp } from './tempfile.gs.js'
|
|
106
|
+
export {
|
|
107
|
+
DirEntry,
|
|
108
|
+
File,
|
|
109
|
+
FileInfo,
|
|
110
|
+
FileMode,
|
|
111
|
+
Getpagesize,
|
|
112
|
+
ModeAppend,
|
|
113
|
+
ModeCharDevice,
|
|
114
|
+
ModeDevice,
|
|
115
|
+
ModeDir,
|
|
116
|
+
ModeExclusive,
|
|
117
|
+
ModeIrregular,
|
|
118
|
+
ModeNamedPipe,
|
|
119
|
+
ModePerm,
|
|
120
|
+
ModeSetgid,
|
|
121
|
+
ModeSetuid,
|
|
122
|
+
ModeSocket,
|
|
123
|
+
ModeSticky,
|
|
124
|
+
ModeSymlink,
|
|
125
|
+
ModeTemporary,
|
|
126
|
+
ModeType,
|
|
127
|
+
SameFile,
|
|
128
|
+
} from './types_js.gs.js'
|
package/gs/os/path.gs.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
import { IsPathSeparator } from "./path_unix.gs.js";
|
|
4
|
+
|
|
5
|
+
// MkdirAll creates a directory named path,
|
|
6
|
+
// along with any necessary parents, and returns nil,
|
|
7
|
+
// or else returns an error.
|
|
8
|
+
// The permission bits perm (before umask) are used for all
|
|
9
|
+
// directories that MkdirAll creates.
|
|
10
|
+
// If path is already a directory, MkdirAll does nothing
|
|
11
|
+
// and returns nil.
|
|
12
|
+
export function MkdirAll(path: string, perm: number): $.GoError {
|
|
13
|
+
return ErrUnimplemented
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// RemoveAll removes path and any children it contains.
|
|
17
|
+
// It removes everything it can but returns the first error
|
|
18
|
+
// it encounters. If the path does not exist, RemoveAll
|
|
19
|
+
// returns nil (no error).
|
|
20
|
+
// If there is an error, it will be of type [*PathError].
|
|
21
|
+
export function RemoveAll(path: string): $.GoError {
|
|
22
|
+
return ErrUnimplemented
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// endsWithDot reports whether the final component of path is ".".
|
|
26
|
+
export function endsWithDot(path: string): boolean {
|
|
27
|
+
if (path == ".") {
|
|
28
|
+
return true
|
|
29
|
+
}
|
|
30
|
+
if ($.len(path) >= 2 && $.indexString(path, $.len(path) - 1) == 46 && IsPathSeparator($.indexString(path, $.len(path) - 2))) {
|
|
31
|
+
return true
|
|
32
|
+
}
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
|
|
3
|
+
// OS-specific path separator
|
|
4
|
+
export let PathSeparator: number = 47
|
|
5
|
+
|
|
6
|
+
// OS-specific path list separator
|
|
7
|
+
export let PathListSeparator: number = 58
|
|
8
|
+
|
|
9
|
+
// IsPathSeparator reports whether c is a directory separator character.
|
|
10
|
+
export function IsPathSeparator(c: number): boolean {
|
|
11
|
+
return 47 == c
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// splitPath returns the base name and parent directory.
|
|
15
|
+
export function splitPath(path: string): [string, string] {
|
|
16
|
+
// if no better parent is found, the path is relative from "here"
|
|
17
|
+
let dirname = "."
|
|
18
|
+
|
|
19
|
+
// Remove all but one leading slash.
|
|
20
|
+
for (; $.len(path) > 1 && $.indexString(path, 0) == 47 && $.indexString(path, 1) == 47; ) {
|
|
21
|
+
path = $.sliceString(path, 1, undefined)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let i = $.len(path) - 1
|
|
25
|
+
|
|
26
|
+
// Remove trailing slashes.
|
|
27
|
+
for (; i > 0 && $.indexString(path, i) == 47; i--) {
|
|
28
|
+
path = $.sliceString(path, undefined, i)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// if no slashes in path, base is path
|
|
32
|
+
let basename = path
|
|
33
|
+
|
|
34
|
+
// Remove leading directory path
|
|
35
|
+
for (i--; i >= 0; i--) {
|
|
36
|
+
if ($.indexString(path, i) == 47) {
|
|
37
|
+
if (i == 0) {
|
|
38
|
+
dirname = $.sliceString(path, undefined, 1)
|
|
39
|
+
} else {
|
|
40
|
+
dirname = $.sliceString(path, undefined, i)
|
|
41
|
+
}
|
|
42
|
+
basename = $.sliceString(path, i + 1, undefined)
|
|
43
|
+
break
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return [dirname, basename]
|
|
48
|
+
}
|
|
49
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { ErrUnimplemented } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
// JavaScript-specific stubs for pidfd operations
|
|
5
|
+
// These operations are Linux-specific and not available in JavaScript
|
|
6
|
+
|
|
7
|
+
// SysProcAttr stub for compatibility
|
|
8
|
+
export interface SysProcAttr {
|
|
9
|
+
// Stub interface for process attributes
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// ensurePidfd ensures pidfd support - stub implementation
|
|
13
|
+
export function ensurePidfd(sysAttr: SysProcAttr | null): [SysProcAttr | null, boolean] {
|
|
14
|
+
return [null, false]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// getPidfd gets a process file descriptor - stub implementation
|
|
18
|
+
export function getPidfd(_: SysProcAttr | null, _usePidfd: boolean): [number, boolean] {
|
|
19
|
+
return [0, false]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// pidfdFind finds a process by pidfd - stub implementation
|
|
23
|
+
export function pidfdFind(_: number): [number, $.GoError] {
|
|
24
|
+
return [0, ErrUnimplemented]
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
import { NewSyscallError } from "./error.gs.js";
|
|
3
|
+
|
|
4
|
+
import * as syscall from "@goscript/syscall/index.js"
|
|
5
|
+
|
|
6
|
+
// Pipe returns a connected pair of Files; reads from r return bytes written to w.
|
|
7
|
+
// It returns the files and an error, if any.
|
|
8
|
+
export function Pipe(): [File | null, File | null, $.GoError] {
|
|
9
|
+
let r: File | null = null
|
|
10
|
+
let w: File | null = null
|
|
11
|
+
let err: $.GoError = null
|
|
12
|
+
{
|
|
13
|
+
// Neither GOOS=js nor GOOS=wasip1 have pipes.
|
|
14
|
+
return [null, null, NewSyscallError("pipe", syscall.ENOSYS)]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|