@tybys/wasm-util 0.8.1 → 0.8.2
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 +31 -26
- package/dist/wasm-util.esm.js +31 -26
- package/dist/wasm-util.esm.min.js +1 -1
- package/dist/wasm-util.js +31 -26
- package/dist/wasm-util.min.js +1 -1
- package/lib/cjs/wasi/preview1.js +26 -26
- package/lib/cjs/wasi/util.js +7 -1
- package/lib/mjs/wasi/preview1.mjs +27 -27
- 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',
|
|
@@ -1965,7 +1970,7 @@ class WASI$1 {
|
|
|
1965
1970
|
const { HEAPU8 } = getMemory(this);
|
|
1966
1971
|
const wasi = _wasi.get(this);
|
|
1967
1972
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_CREATE_DIRECTORY, BigInt(0));
|
|
1968
|
-
let pathString = decoder.decode(HEAPU8
|
|
1973
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1969
1974
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
1970
1975
|
const fs = getFs(this);
|
|
1971
1976
|
fs.mkdirSync(pathString);
|
|
@@ -1979,7 +1984,7 @@ class WASI$1 {
|
|
|
1979
1984
|
const { HEAPU8 } = getMemory(this);
|
|
1980
1985
|
const wasi = _wasi.get(this);
|
|
1981
1986
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_CREATE_DIRECTORY, BigInt(0));
|
|
1982
|
-
let pathString = decoder.decode(HEAPU8
|
|
1987
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1983
1988
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
1984
1989
|
const fs = getFs(this);
|
|
1985
1990
|
await fs.promises.mkdir(pathString);
|
|
@@ -1995,7 +2000,7 @@ class WASI$1 {
|
|
|
1995
2000
|
const { HEAPU8, view } = getMemory(this);
|
|
1996
2001
|
const wasi = _wasi.get(this);
|
|
1997
2002
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_GET, BigInt(0));
|
|
1998
|
-
let pathString = decoder.decode(HEAPU8
|
|
2003
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1999
2004
|
const fs = getFs(this);
|
|
2000
2005
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2001
2006
|
let stat;
|
|
@@ -2017,7 +2022,7 @@ class WASI$1 {
|
|
|
2017
2022
|
const { HEAPU8, view } = getMemory(this);
|
|
2018
2023
|
const wasi = _wasi.get(this);
|
|
2019
2024
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_GET, BigInt(0));
|
|
2020
|
-
let pathString = decoder.decode(HEAPU8
|
|
2025
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2021
2026
|
const fs = getFs(this);
|
|
2022
2027
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2023
2028
|
let stat;
|
|
@@ -2045,7 +2050,7 @@ class WASI$1 {
|
|
|
2045
2050
|
const wasi = _wasi.get(this);
|
|
2046
2051
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_SET_TIMES, BigInt(0));
|
|
2047
2052
|
const fs = getFs(this);
|
|
2048
|
-
const resolvedPath = resolvePathSync(fs, fileDescriptor, decoder.decode(HEAPU8
|
|
2053
|
+
const resolvedPath = resolvePathSync(fs, fileDescriptor, decoder.decode(unsharedSlice(HEAPU8, path, path + path_len)), flags);
|
|
2049
2054
|
if ((fst_flags & 2 /* WasiFstFlag.SET_ATIM_NOW */) === 2 /* WasiFstFlag.SET_ATIM_NOW */) {
|
|
2050
2055
|
atim = BigInt(Date.now() * 1000000);
|
|
2051
2056
|
}
|
|
@@ -2069,7 +2074,7 @@ class WASI$1 {
|
|
|
2069
2074
|
const wasi = _wasi.get(this);
|
|
2070
2075
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_SET_TIMES, BigInt(0));
|
|
2071
2076
|
const fs = getFs(this);
|
|
2072
|
-
const resolvedPath = await resolvePathAsync(fs, fileDescriptor, decoder.decode(HEAPU8
|
|
2077
|
+
const resolvedPath = await resolvePathAsync(fs, fileDescriptor, decoder.decode(unsharedSlice(HEAPU8, path, path + path_len)), flags);
|
|
2073
2078
|
if ((fst_flags & 2 /* WasiFstFlag.SET_ATIM_NOW */) === 2 /* WasiFstFlag.SET_ATIM_NOW */) {
|
|
2074
2079
|
atim = BigInt(Date.now() * 1000000);
|
|
2075
2080
|
}
|
|
@@ -2099,8 +2104,8 @@ class WASI$1 {
|
|
|
2099
2104
|
}
|
|
2100
2105
|
const { HEAPU8 } = getMemory(this);
|
|
2101
2106
|
const fs = getFs(this);
|
|
2102
|
-
const resolvedOldPath = resolvePathSync(fs, oldWrap, decoder.decode(HEAPU8
|
|
2103
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2107
|
+
const resolvedOldPath = resolvePathSync(fs, oldWrap, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)), old_flags);
|
|
2108
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2104
2109
|
fs.linkSync(resolvedOldPath, resolvedNewPath);
|
|
2105
2110
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
2106
2111
|
}, async function path_link(old_fd, old_flags, old_path, old_path_len, new_fd, new_path, new_path_len) {
|
|
@@ -2123,8 +2128,8 @@ class WASI$1 {
|
|
|
2123
2128
|
}
|
|
2124
2129
|
const { HEAPU8 } = getMemory(this);
|
|
2125
2130
|
const fs = getFs(this);
|
|
2126
|
-
const resolvedOldPath = await resolvePathAsync(fs, oldWrap, decoder.decode(HEAPU8
|
|
2127
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2131
|
+
const resolvedOldPath = await resolvePathAsync(fs, oldWrap, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)), old_flags);
|
|
2132
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2128
2133
|
await fs.promises.link(resolvedOldPath, resolvedNewPath);
|
|
2129
2134
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
2130
2135
|
}, ['i32', 'i32', 'i32', 'i32', 'i32', 'i32', 'i32'], ['i32']);
|
|
@@ -2189,7 +2194,7 @@ class WASI$1 {
|
|
|
2189
2194
|
const fileDescriptor = wasi.fds.get(dirfd, neededBase, neededInheriting);
|
|
2190
2195
|
const memory = getMemory(this);
|
|
2191
2196
|
const HEAPU8 = memory.HEAPU8;
|
|
2192
|
-
const pathString = decoder.decode(HEAPU8
|
|
2197
|
+
const pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2193
2198
|
const fs = getFs(this);
|
|
2194
2199
|
const resolved_path = resolvePathSync(fs, fileDescriptor, pathString, dirflags);
|
|
2195
2200
|
const r = fs.openSync(resolved_path, flagsRes, 0o666);
|
|
@@ -2223,7 +2228,7 @@ class WASI$1 {
|
|
|
2223
2228
|
const fileDescriptor = wasi.fds.get(dirfd, neededBase, neededInheriting);
|
|
2224
2229
|
const memory = getMemory(this);
|
|
2225
2230
|
const HEAPU8 = memory.HEAPU8;
|
|
2226
|
-
const pathString = decoder.decode(HEAPU8
|
|
2231
|
+
const pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2227
2232
|
const fs = getFs(this);
|
|
2228
2233
|
const resolved_path = await resolvePathAsync(fs, fileDescriptor, pathString, dirflags);
|
|
2229
2234
|
const r = await fs.promises.open(resolved_path, flagsRes, 0o666);
|
|
@@ -2256,7 +2261,7 @@ class WASI$1 {
|
|
|
2256
2261
|
const { HEAPU8, view } = getMemory(this);
|
|
2257
2262
|
const wasi = _wasi.get(this);
|
|
2258
2263
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_READLINK, BigInt(0));
|
|
2259
|
-
let pathString = decoder.decode(HEAPU8
|
|
2264
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2260
2265
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2261
2266
|
const fs = getFs(this);
|
|
2262
2267
|
const link = fs.readlinkSync(pathString);
|
|
@@ -2280,7 +2285,7 @@ class WASI$1 {
|
|
|
2280
2285
|
const { HEAPU8, view } = getMemory(this);
|
|
2281
2286
|
const wasi = _wasi.get(this);
|
|
2282
2287
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_READLINK, BigInt(0));
|
|
2283
|
-
let pathString = decoder.decode(HEAPU8
|
|
2288
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2284
2289
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2285
2290
|
const fs = getFs(this);
|
|
2286
2291
|
const link = await fs.promises.readlink(pathString);
|
|
@@ -2302,7 +2307,7 @@ class WASI$1 {
|
|
|
2302
2307
|
const { HEAPU8 } = getMemory(this);
|
|
2303
2308
|
const wasi = _wasi.get(this);
|
|
2304
2309
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_REMOVE_DIRECTORY, BigInt(0));
|
|
2305
|
-
let pathString = decoder.decode(HEAPU8
|
|
2310
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2306
2311
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2307
2312
|
const fs = getFs(this);
|
|
2308
2313
|
fs.rmdirSync(pathString);
|
|
@@ -2316,7 +2321,7 @@ class WASI$1 {
|
|
|
2316
2321
|
const { HEAPU8 } = getMemory(this);
|
|
2317
2322
|
const wasi = _wasi.get(this);
|
|
2318
2323
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_REMOVE_DIRECTORY, BigInt(0));
|
|
2319
|
-
let pathString = decoder.decode(HEAPU8
|
|
2324
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2320
2325
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2321
2326
|
const fs = getFs(this);
|
|
2322
2327
|
await fs.promises.rmdir(pathString);
|
|
@@ -2341,8 +2346,8 @@ class WASI$1 {
|
|
|
2341
2346
|
newWrap = wasi.fds.get(new_fd, WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
2342
2347
|
}
|
|
2343
2348
|
const { HEAPU8 } = getMemory(this);
|
|
2344
|
-
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(HEAPU8
|
|
2345
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2349
|
+
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)));
|
|
2350
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2346
2351
|
const fs = getFs(this);
|
|
2347
2352
|
fs.renameSync(resolvedOldPath, resolvedNewPath);
|
|
2348
2353
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
@@ -2365,8 +2370,8 @@ class WASI$1 {
|
|
|
2365
2370
|
newWrap = wasi.fds.get(new_fd, WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
2366
2371
|
}
|
|
2367
2372
|
const { HEAPU8 } = getMemory(this);
|
|
2368
|
-
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(HEAPU8
|
|
2369
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2373
|
+
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)));
|
|
2374
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2370
2375
|
const fs = getFs(this);
|
|
2371
2376
|
await fs.promises.rename(resolvedOldPath, resolvedNewPath);
|
|
2372
2377
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
@@ -2382,8 +2387,8 @@ class WASI$1 {
|
|
|
2382
2387
|
const { HEAPU8 } = getMemory(this);
|
|
2383
2388
|
const wasi = _wasi.get(this);
|
|
2384
2389
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_SYMLINK, BigInt(0));
|
|
2385
|
-
const oldPath = decoder.decode(HEAPU8
|
|
2386
|
-
let newPath = decoder.decode(HEAPU8
|
|
2390
|
+
const oldPath = decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len));
|
|
2391
|
+
let newPath = decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len));
|
|
2387
2392
|
newPath = resolve(fileDescriptor.realPath, newPath);
|
|
2388
2393
|
const fs = getFs(this);
|
|
2389
2394
|
fs.symlinkSync(oldPath, newPath);
|
|
@@ -2399,8 +2404,8 @@ class WASI$1 {
|
|
|
2399
2404
|
const { HEAPU8 } = getMemory(this);
|
|
2400
2405
|
const wasi = _wasi.get(this);
|
|
2401
2406
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_SYMLINK, BigInt(0));
|
|
2402
|
-
const oldPath = decoder.decode(HEAPU8
|
|
2403
|
-
let newPath = decoder.decode(HEAPU8
|
|
2407
|
+
const oldPath = decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len));
|
|
2408
|
+
let newPath = decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len));
|
|
2404
2409
|
newPath = resolve(fileDescriptor.realPath, newPath);
|
|
2405
2410
|
const fs = getFs(this);
|
|
2406
2411
|
await fs.promises.symlink(oldPath, newPath);
|
|
@@ -2415,7 +2420,7 @@ class WASI$1 {
|
|
|
2415
2420
|
const { HEAPU8 } = getMemory(this);
|
|
2416
2421
|
const wasi = _wasi.get(this);
|
|
2417
2422
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_UNLINK_FILE, BigInt(0));
|
|
2418
|
-
let pathString = decoder.decode(HEAPU8
|
|
2423
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2419
2424
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2420
2425
|
const fs = getFs(this);
|
|
2421
2426
|
fs.unlinkSync(pathString);
|
|
@@ -2429,7 +2434,7 @@ class WASI$1 {
|
|
|
2429
2434
|
const { HEAPU8 } = getMemory(this);
|
|
2430
2435
|
const wasi = _wasi.get(this);
|
|
2431
2436
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_UNLINK_FILE, BigInt(0));
|
|
2432
|
-
let pathString = decoder.decode(HEAPU8
|
|
2437
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2433
2438
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2434
2439
|
const fs = getFs(this);
|
|
2435
2440
|
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',
|
|
@@ -1965,7 +1970,7 @@ class WASI$1 {
|
|
|
1965
1970
|
const { HEAPU8 } = getMemory(this);
|
|
1966
1971
|
const wasi = _wasi.get(this);
|
|
1967
1972
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_CREATE_DIRECTORY, BigInt(0));
|
|
1968
|
-
let pathString = decoder.decode(HEAPU8
|
|
1973
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1969
1974
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
1970
1975
|
const fs = getFs(this);
|
|
1971
1976
|
fs.mkdirSync(pathString);
|
|
@@ -1979,7 +1984,7 @@ class WASI$1 {
|
|
|
1979
1984
|
const { HEAPU8 } = getMemory(this);
|
|
1980
1985
|
const wasi = _wasi.get(this);
|
|
1981
1986
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_CREATE_DIRECTORY, BigInt(0));
|
|
1982
|
-
let pathString = decoder.decode(HEAPU8
|
|
1987
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1983
1988
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
1984
1989
|
const fs = getFs(this);
|
|
1985
1990
|
await fs.promises.mkdir(pathString);
|
|
@@ -1995,7 +2000,7 @@ class WASI$1 {
|
|
|
1995
2000
|
const { HEAPU8, view } = getMemory(this);
|
|
1996
2001
|
const wasi = _wasi.get(this);
|
|
1997
2002
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_GET, BigInt(0));
|
|
1998
|
-
let pathString = decoder.decode(HEAPU8
|
|
2003
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1999
2004
|
const fs = getFs(this);
|
|
2000
2005
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2001
2006
|
let stat;
|
|
@@ -2017,7 +2022,7 @@ class WASI$1 {
|
|
|
2017
2022
|
const { HEAPU8, view } = getMemory(this);
|
|
2018
2023
|
const wasi = _wasi.get(this);
|
|
2019
2024
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_GET, BigInt(0));
|
|
2020
|
-
let pathString = decoder.decode(HEAPU8
|
|
2025
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2021
2026
|
const fs = getFs(this);
|
|
2022
2027
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2023
2028
|
let stat;
|
|
@@ -2045,7 +2050,7 @@ class WASI$1 {
|
|
|
2045
2050
|
const wasi = _wasi.get(this);
|
|
2046
2051
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_SET_TIMES, BigInt(0));
|
|
2047
2052
|
const fs = getFs(this);
|
|
2048
|
-
const resolvedPath = resolvePathSync(fs, fileDescriptor, decoder.decode(HEAPU8
|
|
2053
|
+
const resolvedPath = resolvePathSync(fs, fileDescriptor, decoder.decode(unsharedSlice(HEAPU8, path, path + path_len)), flags);
|
|
2049
2054
|
if ((fst_flags & 2 /* WasiFstFlag.SET_ATIM_NOW */) === 2 /* WasiFstFlag.SET_ATIM_NOW */) {
|
|
2050
2055
|
atim = BigInt(Date.now() * 1000000);
|
|
2051
2056
|
}
|
|
@@ -2069,7 +2074,7 @@ class WASI$1 {
|
|
|
2069
2074
|
const wasi = _wasi.get(this);
|
|
2070
2075
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_FILESTAT_SET_TIMES, BigInt(0));
|
|
2071
2076
|
const fs = getFs(this);
|
|
2072
|
-
const resolvedPath = await resolvePathAsync(fs, fileDescriptor, decoder.decode(HEAPU8
|
|
2077
|
+
const resolvedPath = await resolvePathAsync(fs, fileDescriptor, decoder.decode(unsharedSlice(HEAPU8, path, path + path_len)), flags);
|
|
2073
2078
|
if ((fst_flags & 2 /* WasiFstFlag.SET_ATIM_NOW */) === 2 /* WasiFstFlag.SET_ATIM_NOW */) {
|
|
2074
2079
|
atim = BigInt(Date.now() * 1000000);
|
|
2075
2080
|
}
|
|
@@ -2099,8 +2104,8 @@ class WASI$1 {
|
|
|
2099
2104
|
}
|
|
2100
2105
|
const { HEAPU8 } = getMemory(this);
|
|
2101
2106
|
const fs = getFs(this);
|
|
2102
|
-
const resolvedOldPath = resolvePathSync(fs, oldWrap, decoder.decode(HEAPU8
|
|
2103
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2107
|
+
const resolvedOldPath = resolvePathSync(fs, oldWrap, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)), old_flags);
|
|
2108
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2104
2109
|
fs.linkSync(resolvedOldPath, resolvedNewPath);
|
|
2105
2110
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
2106
2111
|
}, async function path_link(old_fd, old_flags, old_path, old_path_len, new_fd, new_path, new_path_len) {
|
|
@@ -2123,8 +2128,8 @@ class WASI$1 {
|
|
|
2123
2128
|
}
|
|
2124
2129
|
const { HEAPU8 } = getMemory(this);
|
|
2125
2130
|
const fs = getFs(this);
|
|
2126
|
-
const resolvedOldPath = await resolvePathAsync(fs, oldWrap, decoder.decode(HEAPU8
|
|
2127
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2131
|
+
const resolvedOldPath = await resolvePathAsync(fs, oldWrap, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)), old_flags);
|
|
2132
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2128
2133
|
await fs.promises.link(resolvedOldPath, resolvedNewPath);
|
|
2129
2134
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
2130
2135
|
}, ['i32', 'i32', 'i32', 'i32', 'i32', 'i32', 'i32'], ['i32']);
|
|
@@ -2189,7 +2194,7 @@ class WASI$1 {
|
|
|
2189
2194
|
const fileDescriptor = wasi.fds.get(dirfd, neededBase, neededInheriting);
|
|
2190
2195
|
const memory = getMemory(this);
|
|
2191
2196
|
const HEAPU8 = memory.HEAPU8;
|
|
2192
|
-
const pathString = decoder.decode(HEAPU8
|
|
2197
|
+
const pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2193
2198
|
const fs = getFs(this);
|
|
2194
2199
|
const resolved_path = resolvePathSync(fs, fileDescriptor, pathString, dirflags);
|
|
2195
2200
|
const r = fs.openSync(resolved_path, flagsRes, 0o666);
|
|
@@ -2223,7 +2228,7 @@ class WASI$1 {
|
|
|
2223
2228
|
const fileDescriptor = wasi.fds.get(dirfd, neededBase, neededInheriting);
|
|
2224
2229
|
const memory = getMemory(this);
|
|
2225
2230
|
const HEAPU8 = memory.HEAPU8;
|
|
2226
|
-
const pathString = decoder.decode(HEAPU8
|
|
2231
|
+
const pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2227
2232
|
const fs = getFs(this);
|
|
2228
2233
|
const resolved_path = await resolvePathAsync(fs, fileDescriptor, pathString, dirflags);
|
|
2229
2234
|
const r = await fs.promises.open(resolved_path, flagsRes, 0o666);
|
|
@@ -2256,7 +2261,7 @@ class WASI$1 {
|
|
|
2256
2261
|
const { HEAPU8, view } = getMemory(this);
|
|
2257
2262
|
const wasi = _wasi.get(this);
|
|
2258
2263
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_READLINK, BigInt(0));
|
|
2259
|
-
let pathString = decoder.decode(HEAPU8
|
|
2264
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2260
2265
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2261
2266
|
const fs = getFs(this);
|
|
2262
2267
|
const link = fs.readlinkSync(pathString);
|
|
@@ -2280,7 +2285,7 @@ class WASI$1 {
|
|
|
2280
2285
|
const { HEAPU8, view } = getMemory(this);
|
|
2281
2286
|
const wasi = _wasi.get(this);
|
|
2282
2287
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_READLINK, BigInt(0));
|
|
2283
|
-
let pathString = decoder.decode(HEAPU8
|
|
2288
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2284
2289
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2285
2290
|
const fs = getFs(this);
|
|
2286
2291
|
const link = await fs.promises.readlink(pathString);
|
|
@@ -2302,7 +2307,7 @@ class WASI$1 {
|
|
|
2302
2307
|
const { HEAPU8 } = getMemory(this);
|
|
2303
2308
|
const wasi = _wasi.get(this);
|
|
2304
2309
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_REMOVE_DIRECTORY, BigInt(0));
|
|
2305
|
-
let pathString = decoder.decode(HEAPU8
|
|
2310
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2306
2311
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2307
2312
|
const fs = getFs(this);
|
|
2308
2313
|
fs.rmdirSync(pathString);
|
|
@@ -2316,7 +2321,7 @@ class WASI$1 {
|
|
|
2316
2321
|
const { HEAPU8 } = getMemory(this);
|
|
2317
2322
|
const wasi = _wasi.get(this);
|
|
2318
2323
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_REMOVE_DIRECTORY, BigInt(0));
|
|
2319
|
-
let pathString = decoder.decode(HEAPU8
|
|
2324
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2320
2325
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2321
2326
|
const fs = getFs(this);
|
|
2322
2327
|
await fs.promises.rmdir(pathString);
|
|
@@ -2341,8 +2346,8 @@ class WASI$1 {
|
|
|
2341
2346
|
newWrap = wasi.fds.get(new_fd, WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
2342
2347
|
}
|
|
2343
2348
|
const { HEAPU8 } = getMemory(this);
|
|
2344
|
-
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(HEAPU8
|
|
2345
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2349
|
+
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)));
|
|
2350
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2346
2351
|
const fs = getFs(this);
|
|
2347
2352
|
fs.renameSync(resolvedOldPath, resolvedNewPath);
|
|
2348
2353
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
@@ -2365,8 +2370,8 @@ class WASI$1 {
|
|
|
2365
2370
|
newWrap = wasi.fds.get(new_fd, WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
2366
2371
|
}
|
|
2367
2372
|
const { HEAPU8 } = getMemory(this);
|
|
2368
|
-
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(HEAPU8
|
|
2369
|
-
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(HEAPU8
|
|
2373
|
+
const resolvedOldPath = resolve(oldWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)));
|
|
2374
|
+
const resolvedNewPath = resolve(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
2370
2375
|
const fs = getFs(this);
|
|
2371
2376
|
await fs.promises.rename(resolvedOldPath, resolvedNewPath);
|
|
2372
2377
|
return 0 /* WasiErrno.ESUCCESS */;
|
|
@@ -2382,8 +2387,8 @@ class WASI$1 {
|
|
|
2382
2387
|
const { HEAPU8 } = getMemory(this);
|
|
2383
2388
|
const wasi = _wasi.get(this);
|
|
2384
2389
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_SYMLINK, BigInt(0));
|
|
2385
|
-
const oldPath = decoder.decode(HEAPU8
|
|
2386
|
-
let newPath = decoder.decode(HEAPU8
|
|
2390
|
+
const oldPath = decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len));
|
|
2391
|
+
let newPath = decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len));
|
|
2387
2392
|
newPath = resolve(fileDescriptor.realPath, newPath);
|
|
2388
2393
|
const fs = getFs(this);
|
|
2389
2394
|
fs.symlinkSync(oldPath, newPath);
|
|
@@ -2399,8 +2404,8 @@ class WASI$1 {
|
|
|
2399
2404
|
const { HEAPU8 } = getMemory(this);
|
|
2400
2405
|
const wasi = _wasi.get(this);
|
|
2401
2406
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_SYMLINK, BigInt(0));
|
|
2402
|
-
const oldPath = decoder.decode(HEAPU8
|
|
2403
|
-
let newPath = decoder.decode(HEAPU8
|
|
2407
|
+
const oldPath = decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len));
|
|
2408
|
+
let newPath = decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len));
|
|
2404
2409
|
newPath = resolve(fileDescriptor.realPath, newPath);
|
|
2405
2410
|
const fs = getFs(this);
|
|
2406
2411
|
await fs.promises.symlink(oldPath, newPath);
|
|
@@ -2415,7 +2420,7 @@ class WASI$1 {
|
|
|
2415
2420
|
const { HEAPU8 } = getMemory(this);
|
|
2416
2421
|
const wasi = _wasi.get(this);
|
|
2417
2422
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_UNLINK_FILE, BigInt(0));
|
|
2418
|
-
let pathString = decoder.decode(HEAPU8
|
|
2423
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2419
2424
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2420
2425
|
const fs = getFs(this);
|
|
2421
2426
|
fs.unlinkSync(pathString);
|
|
@@ -2429,7 +2434,7 @@ class WASI$1 {
|
|
|
2429
2434
|
const { HEAPU8 } = getMemory(this);
|
|
2430
2435
|
const wasi = _wasi.get(this);
|
|
2431
2436
|
const fileDescriptor = wasi.fds.get(fd, WasiRights.PATH_UNLINK_FILE, BigInt(0));
|
|
2432
|
-
let pathString = decoder.decode(HEAPU8
|
|
2437
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
2433
2438
|
pathString = resolve(fileDescriptor.realPath, pathString);
|
|
2434
2439
|
const fs = getFs(this);
|
|
2435
2440
|
await fs.promises.unlink(pathString);
|