]> Cypherpunks.ru repositories - gostls13.git/commitdiff
misc/wasm: fix fs operations in browser
authorRichard Musiol <mail@richard-musiol.de>
Mon, 8 Oct 2018 15:52:52 +0000 (17:52 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 8 Oct 2018 18:33:23 +0000 (18:33 +0000)
The commit 0e4c013 changed the syscall package so it uses the
asynchronous functions of Node.js's fs module.

This commit adapts the stubs of the fs module which are used when using
a browser instead of Node.js.

Fixes #28068.

Change-Id: Ic3a6a8aebb0db06402383bc2fea7642a4501e02c
Reviewed-on: https://go-review.googlesource.com/c/140537
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

misc/wasm/wasm_exec.js

index 94b9552c59606cce2e3107808022f088916b0b0a..815b3fbeff465601aae35d5f6cc1f7a5aa66a420 100644 (file)
                                }
                                return buf.length;
                        },
-                       openSync(path, flags, mode) {
+                       write(fd, buf, offset, length, position, callback) {
+                               if (offset !== 0 || length !== buf.length || position !== null) {
+                                       throw new Error("not implemented");
+                               }
+                               const n = this.writeSync(fd, buf);
+                               callback(null, n);
+                       },
+                       open(path, flags, mode, callback) {
                                const err = new Error("not implemented");
                                err.code = "ENOSYS";
-                               throw err;
+                               callback(err);
                        },
                };
        }