]> Cypherpunks repositories - gostls13.git/commitdiff
lib/wasm: provide fs.constants.O_DIRECTORY definition
authorDmitri Shuralyov <dmitshur@golang.org>
Sat, 7 Dec 2024 22:48:27 +0000 (17:48 -0500)
committerGopher Robot <gobot@golang.org>
Sun, 8 Dec 2024 15:34:47 +0000 (15:34 +0000)
CL 606658 added a constants.Get("O_DIRECTORY").Int() call at init time,
which panics in browsers because O_DIRECTORY is undefined. It needs to
be a JavaScript number to avoid that.

Fixes #70723.

Change-Id: I727240bd25b47401d14a5e1a364d460708803f1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/634455
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Zxilly Chou <zhouxinyu1001@gmail.com>
lib/wasm/wasm_exec.js

index ec96d42db52cc7639e6817e27395317900e63640..d71af9e97e8ca961f816f753afcf3738a50fd6a2 100644 (file)
@@ -14,7 +14,7 @@
        if (!globalThis.fs) {
                let outputBuf = "";
                globalThis.fs = {
-                       constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused
+                       constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1, O_DIRECTORY: -1 }, // unused
                        writeSync(fd, buf) {
                                outputBuf += decoder.decode(buf);
                                const nl = outputBuf.lastIndexOf("\n");