Skip to content

Commit a358256

Browse files
committed
Simplify wasmfs ErrnoError. NFC
This is the same change we already made to the old FS in emscripten-core#21149.
1 parent fc15522 commit a358256

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed

src/lib/libfs.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ FS.staticInit();
5959
#if FS_DEBUG
6060
trackingDelegate: {},
6161
#endif
62-
ErrnoError: null, // set during init
6362
filesystems: null,
6463
syncFSRequests: 0, // we warn if there are multiple in flight at once
6564
#if expectToReceiveOnModule('logReadFiles')

src/lib/libwasmfs.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ addToLibrary({
2121
$wasmFSDevices: {},
2222
$wasmFSDeviceStreams: {},
2323

24-
$FS__postset: `
25-
FS.init();
26-
`,
2724
$FS__deps: [
2825
'$MEMFS',
2926
'$wasmFSPreloadedFiles',
@@ -74,10 +71,13 @@ FS.init();
7471
#endif
7572
],
7673
$FS : {
77-
init() {
78-
FS.ensureErrnoError();
74+
ErrnoError: class extends Error {
75+
name = 'ErrnoError';
76+
message = 'FS error';
77+
constructor(code) {
78+
this.code = code
79+
}
7980
},
80-
ErrnoError: null,
8181
handleError(returnValue) {
8282
// Assume errors correspond to negative returnValues
8383
// since some functions like _wasmfs_open() return positive
@@ -88,16 +88,6 @@ FS.init();
8888

8989
return returnValue;
9090
},
91-
ensureErrnoError() {
92-
if (FS.ErrnoError) return;
93-
FS.ErrnoError = /** @this{Object} */ function ErrnoError(code) {
94-
this.errno = code;
95-
this.message = 'FS error';
96-
this.name = "ErrnoError";
97-
}
98-
FS.ErrnoError.prototype = new Error();
99-
FS.ErrnoError.prototype.constructor = FS.ErrnoError;
100-
},
10191
createDataFile(parent, name, fileData, canRead, canWrite, canOwn) {
10292
FS_createDataFile(parent, name, fileData, canRead, canWrite, canOwn);
10393
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9269
1+
9271
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9277
1+
9276

0 commit comments

Comments
 (0)