@tybys/wasm-util 0.8.1 → 0.8.3
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/dist/wasm-util.esm-bundler.js +47 -28
- package/dist/wasm-util.esm.js +47 -28
- package/dist/wasm-util.esm.min.js +1 -1
- package/dist/wasm-util.js +47 -28
- package/dist/wasm-util.min.js +1 -1
- package/lib/cjs/wasi/preview1.js +42 -28
- package/lib/cjs/wasi/util.js +7 -1
- package/lib/mjs/wasi/preview1.mjs +43 -29
- package/lib/mjs/wasi/util.mjs +5 -0
- package/package.json +1 -1
|
@@ -65,6 +65,11 @@ function sleepBreakIf(delay, breakIf) {
|
|
|
65
65
|
}
|
|
66
66
|
return ret;
|
|
67
67
|
}
|
|
68
|
+
function unsharedSlice(view, start, end) {
|
|
69
|
+
return ((typeof SharedArrayBuffer === 'function' && view.buffer instanceof SharedArrayBuffer) || (Object.prototype.toString.call(view.buffer.constructor) === '[object SharedArrayBuffer]'))
|
|
70
|
+
? view.slice(start, end)
|
|
71
|
+
: view.subarray(start, end);
|
|
72
|
+
}
|
|
68
73
|
|
|
69
74
|
const ignoreNames = [
|
|
70
75
|
'asyncify_get_state',
|
|
@@ -1640,7 +1645,14 @@ class WASI$1 {
|
|
|
1640
1645
|
return HEAPU8.subarray(buf, buf + bufLen);
|
|
1641
1646
|
});
|
|
1642
1647
|
let nread = 0;
|
|
1643
|
-
const buffer =
|
|
1648
|
+
const buffer = (() => {
|
|
1649
|
+
try {
|
|
1650
|
+
return new Uint8Array(new SharedArrayBuffer(totalSize));
|
|
1651
|
+
}
|
|
1652
|
+
catch (_) {
|
|
1653
|
+
return new Uint8Array(totalSize);
|
|
1654
|
+
}
|
|
1655
|
+
})();
|
|
1644
1656
|
buffer._isBuffer = true;
|
|
1645
1657
|
const fs = getFs(this);
|
|
1646
1658
|
const bytesRead = fs.readSync(fileDescriptor.fd, buffer, 0, buffer.length, Number(offset));
|
|
@@ -1737,7 +1749,14 @@ class WASI$1 {
|
|
|
1737
1749
|
nread = buffer ? copyMemory(ioVecs, buffer) : 0;
|
|
1738
1750
|
}
|
|
1739
1751
|
else {
|
|
1740
|
-
buffer =
|
|
1752
|
+
buffer = (() => {
|
|
1753
|
+
try {
|
|
1754
|
+
return new Uint8Array(new SharedArrayBuffer(totalSize));
|
|
1755
|
+
}
|
|
1756
|
+
catch (_) {
|
|
1757
|
+
return new Uint8Array(totalSize);
|
|
1758
|
+
}
|
|
1759
|
+
})();
|
|
1741
1760
|
buffer._isBuffer = true;
|
|
1742
1761
|
const fs = getFs(this);
|
|
1743
1762
|
const bytesRead = fs.readSync(fileDescriptor.fd, buffer, 0, buffer.length, Number(fileDescriptor.pos));
|
|
@@ -1965,7 +1984,7 @@ class WASI$1 {
|
|
|
1965
1984
|
const { HEAPU8 } = getMemory(this);
|
|
1966
1985
|
const wasi = _wasi.get(this);
|
|
1967
1986
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_CREATE_DIRECTORY, BigInt(0));
|
|
1968
|
-
let pathString = decoder.decode(HEAPU8
|
|
1987
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1969
1988
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
1970
1989
|
const fs = getFs(this);
|
|
1971
1990
|
fs.mkdirSync(pathString);
|
|
@@ -1979,7 +1998,7 @@ class WASI$1 {
|
|
|
1979
1998
|
const { HEAPU8 } = getMemory(this);
|
|
1980
1999
|
const wasi = _wasi.get(this);
|
|
1981
2000
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_CREATE_DIRECTORY, BigInt(0));
|
|
1982
|
-
let pathString = decoder.decode(HEAPU8
|
|
2001
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1983
2002
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
1984
2003
|
const fs = getFs(this);
|
|
1985
2004
|
await fs.promises.mkdir(pathString);
|
|
@@ -1995,7 +2014,7 @@ class WASI$1 {
|
|
|
1995
2014
|
const { HEAPU8, view } = getMemory(this);
|
|
1996
2015
|
const wasi = _wasi.get(this);
|
|
1997
2016
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_GET, BigInt(0));
|
|
1998
|
-
let pathString = decoder.decode(HEAPU8
|
|
2017
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1999
2018
|
const fs = getFs(this);
|
|
2000
2019
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2001
2020
|
let stat;
|
|
@@ -2017,7 +2036,7 @@ class WASI$1 {
|
|
|
2017
2036
|
const { HEAPU8, view } = getMemory(this);
|
|
2018
2037
|
const wasi = _wasi.get(this);
|
|
2019
2038
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_GET, BigInt(0));
|
|
2020
|
-
let pathString = decoder.decode(HEAPU8
|
|
2039
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2021
2040
|
const fs = getFs(this);
|
|
2022
2041
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2023
2042
|
let stat;
|
|
@@ -2045,7 +2064,7 @@ class WASI$1 {
|
|
|
2045
2064
|
const wasi = _wasi.get(this);
|
|
2046
2065
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_SET_TIMES, BigInt(0));
|
|
2047
2066
|
const fs = getFs(this);
|
|
2048
|
-
const resolvedPath = resolvePathSync(fs, fileDescriptor, decoder.decode(HEAPU8
|
|
2067
|
+
const resolvedPath = resolvePathSync(fs, fileDescriptor, decoder.decode(unsharedSlice(HEAPU8, path, path + path_len)), flags);
|
|
2049
2068
|
if ((fst_flags & 2 /* WasiFstFlag.SET_ATIM_NOW */) === 2 /* WasiFstFlag.SET_ATIM_NOW */) {
|
|
2050
2069
|
atim = BigInt(Date.now() * 1000000);
|
|
2051
2070
|
}
|
|
@@ -2069,7 +2088,7 @@ class WASI$1 {
|
|
|
2069
2088
|
const wasi = _wasi.get(this);
|
|
2070
2089
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_SET_TIMES, BigInt(0));
|
|
2071
2090
|
const fs = getFs(this);
|
|
2072
|
-
const resolvedPath = await resolvePathAsync(fs, fileDescriptor, decoder.decode(HEAPU8
|
|
2091
|
+
const resolvedPath = await resolvePathAsync(fs, fileDescriptor, decoder.decode(unsharedSlice(HEAPU8, path, path + path_len)), flags);
|
|
2073
2092
|
if ((fst_flags & 2 /* WasiFstFlag.SET_ATIM_NOW */) === 2 /* WasiFstFlag.SET_ATIM_NOW */) {
|
|
2074
2093
|
atim = BigInt(Date.now() * 1000000);
|
|
2075
2094
|
}
|
|
@@ -2099,8 +2118,8 @@ class WASI$1 {
|
|
|
2099
2118
|
}
|
|
2100
2119
|
const { HEAPU8 } = getMemory(this);
|
|
2101
2120
|
const fs = getFs(this);
|
|
2102
|
-
const resolvedOldPath = resolvePathSync(fs, oldWrap, decoder.decode(HEAPU8
|
|
2103
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2121
|
+
const resolvedOldPath = resolvePathSync(fs, oldWrap, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)), old_flags);
|
|
2122
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2104
2123
|
fs.linkSync(resolvedOldPath, resolvedNewPath);
|
|
2105
2124
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
2106
2125
|
}, async function path_link(old_fd, old_flags, old_path, old_path_len, new_fd, new_path, new_path_len) {
|
|
@@ -2123,8 +2142,8 @@ class WASI$1 {
|
|
|
2123
2142
|
}
|
|
2124
2143
|
const { HEAPU8 } = getMemory(this);
|
|
2125
2144
|
const fs = getFs(this);
|
|
2126
|
-
const resolvedOldPath = await resolvePathAsync(fs, oldWrap, decoder.decode(HEAPU8
|
|
2127
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2145
|
+
const resolvedOldPath = await resolvePathAsync(fs, oldWrap, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)), old_flags);
|
|
2146
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2128
2147
|
await fs.promises.link(resolvedOldPath, resolvedNewPath);
|
|
2129
2148
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
2130
2149
|
}, ['i32', 'i32', 'i32', 'i32', 'i32', 'i32', 'i32'], ['i32']);
|
|
@@ -2189,7 +2208,7 @@ class WASI$1 {
|
|
|
2189
2208
|
const fileDescriptor = wasi.fds.get(dirfd, neededBase, neededInheriting);
|
|
2190
2209
|
const memory = getMemory(this);
|
|
2191
2210
|
const HEAPU8 = memory.HEAPU8;
|
|
2192
|
-
const pathString = decoder.decode(HEAPU8
|
|
2211
|
+
const pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2193
2212
|
const fs = getFs(this);
|
|
2194
2213
|
const resolved_path = resolvePathSync(fs, fileDescriptor, pathString, dirflags);
|
|
2195
2214
|
const r = fs.openSync(resolved_path, flagsRes, 0o666);
|
|
@@ -2223,7 +2242,7 @@ class WASI$1 {
|
|
|
2223
2242
|
const fileDescriptor = wasi.fds.get(dirfd, neededBase, neededInheriting);
|
|
2224
2243
|
const memory = getMemory(this);
|
|
2225
2244
|
const HEAPU8 = memory.HEAPU8;
|
|
2226
|
-
const pathString = decoder.decode(HEAPU8
|
|
2245
|
+
const pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2227
2246
|
const fs = getFs(this);
|
|
2228
2247
|
const resolved_path = await resolvePathAsync(fs, fileDescriptor, pathString, dirflags);
|
|
2229
2248
|
const r = await fs.promises.open(resolved_path, flagsRes, 0o666);
|
|
@@ -2256,7 +2275,7 @@ class WASI$1 {
|
|
|
2256
2275
|
const { HEAPU8, view } = getMemory(this);
|
|
2257
2276
|
const wasi = _wasi.get(this);
|
|
2258
2277
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_READLINK, BigInt(0));
|
|
2259
|
-
let pathString = decoder.decode(HEAPU8
|
|
2278
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2260
2279
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2261
2280
|
const fs = getFs(this);
|
|
2262
2281
|
const link = fs.readlinkSync(pathString);
|
|
@@ -2280,7 +2299,7 @@ class WASI$1 {
|
|
|
2280
2299
|
const { HEAPU8, view } = getMemory(this);
|
|
2281
2300
|
const wasi = _wasi.get(this);
|
|
2282
2301
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_READLINK, BigInt(0));
|
|
2283
|
-
let pathString = decoder.decode(HEAPU8
|
|
2302
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2284
2303
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2285
2304
|
const fs = getFs(this);
|
|
2286
2305
|
const link = await fs.promises.readlink(pathString);
|
|
@@ -2302,7 +2321,7 @@ class WASI$1 {
|
|
|
2302
2321
|
const { HEAPU8 } = getMemory(this);
|
|
2303
2322
|
const wasi = _wasi.get(this);
|
|
2304
2323
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_REMOVE_DIRECTORY, BigInt(0));
|
|
2305
|
-
let pathString = decoder.decode(HEAPU8
|
|
2324
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2306
2325
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2307
2326
|
const fs = getFs(this);
|
|
2308
2327
|
fs.rmdirSync(pathString);
|
|
@@ -2316,7 +2335,7 @@ class WASI$1 {
|
|
|
2316
2335
|
const { HEAPU8 } = getMemory(this);
|
|
2317
2336
|
const wasi = _wasi.get(this);
|
|
2318
2337
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_REMOVE_DIRECTORY, BigInt(0));
|
|
2319
|
-
let pathString = decoder.decode(HEAPU8
|
|
2338
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2320
2339
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2321
2340
|
const fs = getFs(this);
|
|
2322
2341
|
await fs.promises.rmdir(pathString);
|
|
@@ -2341,8 +2360,8 @@ class WASI$1 {
|
|
|
2341
2360
|
newWrap = wasi.fds.get(new_fd, WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
2342
2361
|
}
|
|
2343
2362
|
const { HEAPU8 } = getMemory(this);
|
|
2344
|
-
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(HEAPU8
|
|
2345
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2363
|
+
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)));
|
|
2364
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2346
2365
|
const fs = getFs(this);
|
|
2347
2366
|
fs.renameSync(resolvedOldPath, resolvedNewPath);
|
|
2348
2367
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
@@ -2365,8 +2384,8 @@ class WASI$1 {
|
|
|
2365
2384
|
newWrap = wasi.fds.get(new_fd, WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
2366
2385
|
}
|
|
2367
2386
|
const { HEAPU8 } = getMemory(this);
|
|
2368
|
-
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(HEAPU8
|
|
2369
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2387
|
+
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)));
|
|
2388
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2370
2389
|
const fs = getFs(this);
|
|
2371
2390
|
await fs.promises.rename(resolvedOldPath, resolvedNewPath);
|
|
2372
2391
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
@@ -2382,8 +2401,8 @@ class WASI$1 {
|
|
|
2382
2401
|
const { HEAPU8 } = getMemory(this);
|
|
2383
2402
|
const wasi = _wasi.get(this);
|
|
2384
2403
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_SYMLINK, BigInt(0));
|
|
2385
|
-
const oldPath = decoder.decode(HEAPU8
|
|
2386
|
-
let newPath = decoder.decode(HEAPU8
|
|
2404
|
+
const oldPath = decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len));
|
|
2405
|
+
let newPath = decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len));
|
|
2387
2406
|
newPath = resolve(fileDescriptor.realPath, newPath);
|
|
2388
2407
|
const fs = getFs(this);
|
|
2389
2408
|
fs.symlinkSync(oldPath, newPath);
|
|
@@ -2399,8 +2418,8 @@ class WASI$1 {
|
|
|
2399
2418
|
const { HEAPU8 } = getMemory(this);
|
|
2400
2419
|
const wasi = _wasi.get(this);
|
|
2401
2420
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_SYMLINK, BigInt(0));
|
|
2402
|
-
const oldPath = decoder.decode(HEAPU8
|
|
2403
|
-
let newPath = decoder.decode(HEAPU8
|
|
2421
|
+
const oldPath = decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len));
|
|
2422
|
+
let newPath = decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len));
|
|
2404
2423
|
newPath = resolve(fileDescriptor.realPath, newPath);
|
|
2405
2424
|
const fs = getFs(this);
|
|
2406
2425
|
await fs.promises.symlink(oldPath, newPath);
|
|
@@ -2415,7 +2434,7 @@ class WASI$1 {
|
|
|
2415
2434
|
const { HEAPU8 } = getMemory(this);
|
|
2416
2435
|
const wasi = _wasi.get(this);
|
|
2417
2436
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_UNLINK_FILE, BigInt(0));
|
|
2418
|
-
let pathString = decoder.decode(HEAPU8
|
|
2437
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2419
2438
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2420
2439
|
const fs = getFs(this);
|
|
2421
2440
|
fs.unlinkSync(pathString);
|
|
@@ -2429,7 +2448,7 @@ class WASI$1 {
|
|
|
2429
2448
|
const { HEAPU8 } = getMemory(this);
|
|
2430
2449
|
const wasi = _wasi.get(this);
|
|
2431
2450
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_UNLINK_FILE, BigInt(0));
|
|
2432
|
-
let pathString = decoder.decode(HEAPU8
|
|
2451
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2433
2452
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2434
2453
|
const fs = getFs(this);
|
|
2435
2454
|
await fs.promises.unlink(pathString);
|
package/dist/wasm-util.esm.js
CHANGED
|
@@ -65,6 +65,11 @@ function sleepBreakIf(delay, breakIf) {
|
|
|
65
65
|
}
|
|
66
66
|
return ret;
|
|
67
67
|
}
|
|
68
|
+
function unsharedSlice(view, start, end) {
|
|
69
|
+
return ((typeof SharedArrayBuffer === 'function' && view.buffer instanceof SharedArrayBuffer) || (Object.prototype.toString.call(view.buffer.constructor) === '[object SharedArrayBuffer]'))
|
|
70
|
+
? view.slice(start, end)
|
|
71
|
+
: view.subarray(start, end);
|
|
72
|
+
}
|
|
68
73
|
|
|
69
74
|
const ignoreNames = [
|
|
70
75
|
'asyncify_get_state',
|
|
@@ -1640,7 +1645,14 @@ class WASI$1 {
|
|
|
1640
1645
|
return HEAPU8.subarray(buf, buf + bufLen);
|
|
1641
1646
|
});
|
|
1642
1647
|
let nread = 0;
|
|
1643
|
-
const buffer =
|
|
1648
|
+
const buffer = (() => {
|
|
1649
|
+
try {
|
|
1650
|
+
return new Uint8Array(new SharedArrayBuffer(totalSize));
|
|
1651
|
+
}
|
|
1652
|
+
catch (_) {
|
|
1653
|
+
return new Uint8Array(totalSize);
|
|
1654
|
+
}
|
|
1655
|
+
})();
|
|
1644
1656
|
buffer._isBuffer = true;
|
|
1645
1657
|
const fs = getFs(this);
|
|
1646
1658
|
const bytesRead = fs.readSync(fileDescriptor.fd, buffer, 0, buffer.length, Number(offset));
|
|
@@ -1737,7 +1749,14 @@ class WASI$1 {
|
|
|
1737
1749
|
nread = buffer ? copyMemory(ioVecs, buffer) : 0;
|
|
1738
1750
|
}
|
|
1739
1751
|
else {
|
|
1740
|
-
buffer =
|
|
1752
|
+
buffer = (() => {
|
|
1753
|
+
try {
|
|
1754
|
+
return new Uint8Array(new SharedArrayBuffer(totalSize));
|
|
1755
|
+
}
|
|
1756
|
+
catch (_) {
|
|
1757
|
+
return new Uint8Array(totalSize);
|
|
1758
|
+
}
|
|
1759
|
+
})();
|
|
1741
1760
|
buffer._isBuffer = true;
|
|
1742
1761
|
const fs = getFs(this);
|
|
1743
1762
|
const bytesRead = fs.readSync(fileDescriptor.fd, buffer, 0, buffer.length, Number(fileDescriptor.pos));
|
|
@@ -1965,7 +1984,7 @@ class WASI$1 {
|
|
|
1965
1984
|
const { HEAPU8 } = getMemory(this);
|
|
1966
1985
|
const wasi = _wasi.get(this);
|
|
1967
1986
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_CREATE_DIRECTORY, BigInt(0));
|
|
1968
|
-
let pathString = decoder.decode(HEAPU8
|
|
1987
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1969
1988
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
1970
1989
|
const fs = getFs(this);
|
|
1971
1990
|
fs.mkdirSync(pathString);
|
|
@@ -1979,7 +1998,7 @@ class WASI$1 {
|
|
|
1979
1998
|
const { HEAPU8 } = getMemory(this);
|
|
1980
1999
|
const wasi = _wasi.get(this);
|
|
1981
2000
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_CREATE_DIRECTORY, BigInt(0));
|
|
1982
|
-
let pathString = decoder.decode(HEAPU8
|
|
2001
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1983
2002
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
1984
2003
|
const fs = getFs(this);
|
|
1985
2004
|
await fs.promises.mkdir(pathString);
|
|
@@ -1995,7 +2014,7 @@ class WASI$1 {
|
|
|
1995
2014
|
const { HEAPU8, view } = getMemory(this);
|
|
1996
2015
|
const wasi = _wasi.get(this);
|
|
1997
2016
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_GET, BigInt(0));
|
|
1998
|
-
let pathString = decoder.decode(HEAPU8
|
|
2017
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1999
2018
|
const fs = getFs(this);
|
|
2000
2019
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2001
2020
|
let stat;
|
|
@@ -2017,7 +2036,7 @@ class WASI$1 {
|
|
|
2017
2036
|
const { HEAPU8, view } = getMemory(this);
|
|
2018
2037
|
const wasi = _wasi.get(this);
|
|
2019
2038
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_GET, BigInt(0));
|
|
2020
|
-
let pathString = decoder.decode(HEAPU8
|
|
2039
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2021
2040
|
const fs = getFs(this);
|
|
2022
2041
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2023
2042
|
let stat;
|
|
@@ -2045,7 +2064,7 @@ class WASI$1 {
|
|
|
2045
2064
|
const wasi = _wasi.get(this);
|
|
2046
2065
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_SET_TIMES, BigInt(0));
|
|
2047
2066
|
const fs = getFs(this);
|
|
2048
|
-
const resolvedPath = resolvePathSync(fs, fileDescriptor, decoder.decode(HEAPU8
|
|
2067
|
+
const resolvedPath = resolvePathSync(fs, fileDescriptor, decoder.decode(unsharedSlice(HEAPU8, path, path + path_len)), flags);
|
|
2049
2068
|
if ((fst_flags & 2 /* WasiFstFlag.SET_ATIM_NOW */) === 2 /* WasiFstFlag.SET_ATIM_NOW */) {
|
|
2050
2069
|
atim = BigInt(Date.now() * 1000000);
|
|
2051
2070
|
}
|
|
@@ -2069,7 +2088,7 @@ class WASI$1 {
|
|
|
2069
2088
|
const wasi = _wasi.get(this);
|
|
2070
2089
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_SET_TIMES, BigInt(0));
|
|
2071
2090
|
const fs = getFs(this);
|
|
2072
|
-
const resolvedPath = await resolvePathAsync(fs, fileDescriptor, decoder.decode(HEAPU8
|
|
2091
|
+
const resolvedPath = await resolvePathAsync(fs, fileDescriptor, decoder.decode(unsharedSlice(HEAPU8, path, path + path_len)), flags);
|
|
2073
2092
|
if ((fst_flags & 2 /* WasiFstFlag.SET_ATIM_NOW */) === 2 /* WasiFstFlag.SET_ATIM_NOW */) {
|
|
2074
2093
|
atim = BigInt(Date.now() * 1000000);
|
|
2075
2094
|
}
|
|
@@ -2099,8 +2118,8 @@ class WASI$1 {
|
|
|
2099
2118
|
}
|
|
2100
2119
|
const { HEAPU8 } = getMemory(this);
|
|
2101
2120
|
const fs = getFs(this);
|
|
2102
|
-
const resolvedOldPath = resolvePathSync(fs, oldWrap, decoder.decode(HEAPU8
|
|
2103
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2121
|
+
const resolvedOldPath = resolvePathSync(fs, oldWrap, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)), old_flags);
|
|
2122
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2104
2123
|
fs.linkSync(resolvedOldPath, resolvedNewPath);
|
|
2105
2124
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
2106
2125
|
}, async function path_link(old_fd, old_flags, old_path, old_path_len, new_fd, new_path, new_path_len) {
|
|
@@ -2123,8 +2142,8 @@ class WASI$1 {
|
|
|
2123
2142
|
}
|
|
2124
2143
|
const { HEAPU8 } = getMemory(this);
|
|
2125
2144
|
const fs = getFs(this);
|
|
2126
|
-
const resolvedOldPath = await resolvePathAsync(fs, oldWrap, decoder.decode(HEAPU8
|
|
2127
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2145
|
+
const resolvedOldPath = await resolvePathAsync(fs, oldWrap, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)), old_flags);
|
|
2146
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2128
2147
|
await fs.promises.link(resolvedOldPath, resolvedNewPath);
|
|
2129
2148
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
2130
2149
|
}, ['i32', 'i32', 'i32', 'i32', 'i32', 'i32', 'i32'], ['i32']);
|
|
@@ -2189,7 +2208,7 @@ class WASI$1 {
|
|
|
2189
2208
|
const fileDescriptor = wasi.fds.get(dirfd, neededBase, neededInheriting);
|
|
2190
2209
|
const memory = getMemory(this);
|
|
2191
2210
|
const HEAPU8 = memory.HEAPU8;
|
|
2192
|
-
const pathString = decoder.decode(HEAPU8
|
|
2211
|
+
const pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2193
2212
|
const fs = getFs(this);
|
|
2194
2213
|
const resolved_path = resolvePathSync(fs, fileDescriptor, pathString, dirflags);
|
|
2195
2214
|
const r = fs.openSync(resolved_path, flagsRes, 0o666);
|
|
@@ -2223,7 +2242,7 @@ class WASI$1 {
|
|
|
2223
2242
|
const fileDescriptor = wasi.fds.get(dirfd, neededBase, neededInheriting);
|
|
2224
2243
|
const memory = getMemory(this);
|
|
2225
2244
|
const HEAPU8 = memory.HEAPU8;
|
|
2226
|
-
const pathString = decoder.decode(HEAPU8
|
|
2245
|
+
const pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2227
2246
|
const fs = getFs(this);
|
|
2228
2247
|
const resolved_path = await resolvePathAsync(fs, fileDescriptor, pathString, dirflags);
|
|
2229
2248
|
const r = await fs.promises.open(resolved_path, flagsRes, 0o666);
|
|
@@ -2256,7 +2275,7 @@ class WASI$1 {
|
|
|
2256
2275
|
const { HEAPU8, view } = getMemory(this);
|
|
2257
2276
|
const wasi = _wasi.get(this);
|
|
2258
2277
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_READLINK, BigInt(0));
|
|
2259
|
-
let pathString = decoder.decode(HEAPU8
|
|
2278
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2260
2279
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2261
2280
|
const fs = getFs(this);
|
|
2262
2281
|
const link = fs.readlinkSync(pathString);
|
|
@@ -2280,7 +2299,7 @@ class WASI$1 {
|
|
|
2280
2299
|
const { HEAPU8, view } = getMemory(this);
|
|
2281
2300
|
const wasi = _wasi.get(this);
|
|
2282
2301
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_READLINK, BigInt(0));
|
|
2283
|
-
let pathString = decoder.decode(HEAPU8
|
|
2302
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2284
2303
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2285
2304
|
const fs = getFs(this);
|
|
2286
2305
|
const link = await fs.promises.readlink(pathString);
|
|
@@ -2302,7 +2321,7 @@ class WASI$1 {
|
|
|
2302
2321
|
const { HEAPU8 } = getMemory(this);
|
|
2303
2322
|
const wasi = _wasi.get(this);
|
|
2304
2323
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_REMOVE_DIRECTORY, BigInt(0));
|
|
2305
|
-
let pathString = decoder.decode(HEAPU8
|
|
2324
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2306
2325
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2307
2326
|
const fs = getFs(this);
|
|
2308
2327
|
fs.rmdirSync(pathString);
|
|
@@ -2316,7 +2335,7 @@ class WASI$1 {
|
|
|
2316
2335
|
const { HEAPU8 } = getMemory(this);
|
|
2317
2336
|
const wasi = _wasi.get(this);
|
|
2318
2337
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_REMOVE_DIRECTORY, BigInt(0));
|
|
2319
|
-
let pathString = decoder.decode(HEAPU8
|
|
2338
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2320
2339
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2321
2340
|
const fs = getFs(this);
|
|
2322
2341
|
await fs.promises.rmdir(pathString);
|
|
@@ -2341,8 +2360,8 @@ class WASI$1 {
|
|
|
2341
2360
|
newWrap = wasi.fds.get(new_fd, WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
2342
2361
|
}
|
|
2343
2362
|
const { HEAPU8 } = getMemory(this);
|
|
2344
|
-
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(HEAPU8
|
|
2345
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2363
|
+
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)));
|
|
2364
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2346
2365
|
const fs = getFs(this);
|
|
2347
2366
|
fs.renameSync(resolvedOldPath, resolvedNewPath);
|
|
2348
2367
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
@@ -2365,8 +2384,8 @@ class WASI$1 {
|
|
|
2365
2384
|
newWrap = wasi.fds.get(new_fd, WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
2366
2385
|
}
|
|
2367
2386
|
const { HEAPU8 } = getMemory(this);
|
|
2368
|
-
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(HEAPU8
|
|
2369
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2387
|
+
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)));
|
|
2388
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2370
2389
|
const fs = getFs(this);
|
|
2371
2390
|
await fs.promises.rename(resolvedOldPath, resolvedNewPath);
|
|
2372
2391
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
@@ -2382,8 +2401,8 @@ class WASI$1 {
|
|
|
2382
2401
|
const { HEAPU8 } = getMemory(this);
|
|
2383
2402
|
const wasi = _wasi.get(this);
|
|
2384
2403
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_SYMLINK, BigInt(0));
|
|
2385
|
-
const oldPath = decoder.decode(HEAPU8
|
|
2386
|
-
let newPath = decoder.decode(HEAPU8
|
|
2404
|
+
const oldPath = decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len));
|
|
2405
|
+
let newPath = decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len));
|
|
2387
2406
|
newPath = resolve(fileDescriptor.realPath, newPath);
|
|
2388
2407
|
const fs = getFs(this);
|
|
2389
2408
|
fs.symlinkSync(oldPath, newPath);
|
|
@@ -2399,8 +2418,8 @@ class WASI$1 {
|
|
|
2399
2418
|
const { HEAPU8 } = getMemory(this);
|
|
2400
2419
|
const wasi = _wasi.get(this);
|
|
2401
2420
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_SYMLINK, BigInt(0));
|
|
2402
|
-
const oldPath = decoder.decode(HEAPU8
|
|
2403
|
-
let newPath = decoder.decode(HEAPU8
|
|
2421
|
+
const oldPath = decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len));
|
|
2422
|
+
let newPath = decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len));
|
|
2404
2423
|
newPath = resolve(fileDescriptor.realPath, newPath);
|
|
2405
2424
|
const fs = getFs(this);
|
|
2406
2425
|
await fs.promises.symlink(oldPath, newPath);
|
|
@@ -2415,7 +2434,7 @@ class WASI$1 {
|
|
|
2415
2434
|
const { HEAPU8 } = getMemory(this);
|
|
2416
2435
|
const wasi = _wasi.get(this);
|
|
2417
2436
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_UNLINK_FILE, BigInt(0));
|
|
2418
|
-
let pathString = decoder.decode(HEAPU8
|
|
2437
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2419
2438
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2420
2439
|
const fs = getFs(this);
|
|
2421
2440
|
fs.unlinkSync(pathString);
|
|
@@ -2429,7 +2448,7 @@ class WASI$1 {
|
|
|
2429
2448
|
const { HEAPU8 } = getMemory(this);
|
|
2430
2449
|
const wasi = _wasi.get(this);
|
|
2431
2450
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_UNLINK_FILE, BigInt(0));
|
|
2432
|
-
let pathString = decoder.decode(HEAPU8
|
|
2451
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2433
2452
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2434
2453
|
const fs = getFs(this);
|
|
2435
2454
|
await fs.promises.unlink(pathString);
|