aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/fs_js.go
diff options
context:
space:
mode:
authorKir Kolyshkin <kolyshkin@gmail.com>2024-08-19 17:13:00 -0700
committerGopher Robot <gobot@golang.org>2024-08-21 18:23:25 +0000
commitf0f4e2d0af78618b89fdb13d557faee193cbaa4c (patch)
treec7302aea0870de7d375547d05c5168f614b49041 /src/syscall/fs_js.go
parent92dd05682c514bc84352ec716280b5d3a66399e4 (diff)
downloadgo-f0f4e2d0af78618b89fdb13d557faee193cbaa4c.tar.xz
syscall: add O_DIRECTORY for js
Change-Id: I2022fa27b072f9b34413a04a794aeb6d3c02166c Reviewed-on: https://go-review.googlesource.com/c/go/+/606658 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/syscall/fs_js.go')
-rw-r--r--src/syscall/fs_js.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/syscall/fs_js.go b/src/syscall/fs_js.go
index b6138ebeb1..111ce4f5c1 100644
--- a/src/syscall/fs_js.go
+++ b/src/syscall/fs_js.go
@@ -23,12 +23,13 @@ var constants = jsFS.Get("constants")
var uint8Array = js.Global().Get("Uint8Array")
var (
- nodeWRONLY = constants.Get("O_WRONLY").Int()
- nodeRDWR = constants.Get("O_RDWR").Int()
- nodeCREATE = constants.Get("O_CREAT").Int()
- nodeTRUNC = constants.Get("O_TRUNC").Int()
- nodeAPPEND = constants.Get("O_APPEND").Int()
- nodeEXCL = constants.Get("O_EXCL").Int()
+ nodeWRONLY = constants.Get("O_WRONLY").Int()
+ nodeRDWR = constants.Get("O_RDWR").Int()
+ nodeCREATE = constants.Get("O_CREAT").Int()
+ nodeTRUNC = constants.Get("O_TRUNC").Int()
+ nodeAPPEND = constants.Get("O_APPEND").Int()
+ nodeEXCL = constants.Get("O_EXCL").Int()
+ nodeDIRECTORY = constants.Get("O_DIRECTORY").Int()
)
type jsFile struct {
@@ -83,6 +84,9 @@ func Open(path string, openmode int, perm uint32) (int, error) {
if openmode&O_SYNC != 0 {
return 0, errors.New("syscall.Open: O_SYNC is not supported by js/wasm")
}
+ if openmode&O_DIRECTORY != 0 {
+ flags |= nodeDIRECTORY
+ }
jsFD, err := fsCall("open", path, flags, perm)
if err != nil {