2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2021-02-04 17:18:32 -05:00
|
|
|
"use strict";
|
2020-07-19 13:49:44 -04:00
|
|
|
|
|
|
|
((window) => {
|
2020-09-16 16:22:43 -04:00
|
|
|
const core = window.Deno.core;
|
2022-08-11 09:56:56 -04:00
|
|
|
const ops = core.ops;
|
2021-07-03 11:17:23 -04:00
|
|
|
const {
|
|
|
|
Date,
|
2022-02-01 12:06:11 -05:00
|
|
|
DatePrototype,
|
2021-07-03 11:17:23 -04:00
|
|
|
MathTrunc,
|
2022-02-01 12:06:11 -05:00
|
|
|
ObjectPrototypeIsPrototypeOf,
|
2022-12-19 21:37:50 -05:00
|
|
|
SafeArrayIterator,
|
2021-07-03 11:17:23 -04:00
|
|
|
SymbolAsyncIterator,
|
|
|
|
SymbolIterator,
|
2022-09-22 05:09:25 -04:00
|
|
|
Function,
|
|
|
|
ObjectEntries,
|
|
|
|
Uint32Array,
|
2021-07-03 11:17:23 -04:00
|
|
|
} = window.__bootstrap.primordials;
|
2020-07-19 13:49:44 -04:00
|
|
|
const { pathFromURL } = window.__bootstrap.util;
|
|
|
|
const build = window.__bootstrap.build.build;
|
|
|
|
|
|
|
|
function chmodSync(path, mode) {
|
2022-09-22 05:09:25 -04:00
|
|
|
ops.op_chmod_sync(pathFromURL(path), mode);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function chmod(path, mode) {
|
2022-09-22 05:09:25 -04:00
|
|
|
await core.opAsync("op_chmod_async", pathFromURL(path), mode);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function chownSync(
|
|
|
|
path,
|
|
|
|
uid,
|
|
|
|
gid,
|
|
|
|
) {
|
2022-09-22 05:09:25 -04:00
|
|
|
ops.op_chown_sync(pathFromURL(path), uid, gid);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function chown(
|
|
|
|
path,
|
|
|
|
uid,
|
|
|
|
gid,
|
|
|
|
) {
|
2021-04-12 15:55:05 -04:00
|
|
|
await core.opAsync(
|
2020-09-16 16:22:43 -04:00
|
|
|
"op_chown_async",
|
2022-09-22 05:09:25 -04:00
|
|
|
pathFromURL(path),
|
|
|
|
uid,
|
|
|
|
gid,
|
2020-09-16 16:22:43 -04:00
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function copyFileSync(
|
|
|
|
fromPath,
|
|
|
|
toPath,
|
|
|
|
) {
|
2022-09-22 05:09:25 -04:00
|
|
|
ops.op_copy_file_sync(
|
|
|
|
pathFromURL(fromPath),
|
|
|
|
pathFromURL(toPath),
|
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function copyFile(
|
|
|
|
fromPath,
|
|
|
|
toPath,
|
|
|
|
) {
|
2022-09-22 05:09:25 -04:00
|
|
|
await core.opAsync(
|
|
|
|
"op_copy_file_async",
|
|
|
|
pathFromURL(fromPath),
|
|
|
|
pathFromURL(toPath),
|
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function cwd() {
|
2022-08-11 09:56:56 -04:00
|
|
|
return ops.op_cwd();
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function chdir(directory) {
|
2022-08-11 09:56:56 -04:00
|
|
|
ops.op_chdir(pathFromURL(directory));
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function makeTempDirSync(options = {}) {
|
2022-08-11 09:56:56 -04:00
|
|
|
return ops.op_make_temp_dir_sync(options);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function makeTempDir(options = {}) {
|
2021-04-12 15:55:05 -04:00
|
|
|
return core.opAsync("op_make_temp_dir_async", options);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function makeTempFileSync(options = {}) {
|
2022-08-11 09:56:56 -04:00
|
|
|
return ops.op_make_temp_file_sync(options);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function makeTempFile(options = {}) {
|
2021-04-12 15:55:05 -04:00
|
|
|
return core.opAsync("op_make_temp_file_async", options);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function mkdirArgs(path, options) {
|
2020-10-27 08:21:32 -04:00
|
|
|
const args = { path: pathFromURL(path), recursive: false };
|
2020-07-19 13:49:44 -04:00
|
|
|
if (options != null) {
|
|
|
|
if (typeof options.recursive == "boolean") {
|
|
|
|
args.recursive = options.recursive;
|
|
|
|
}
|
|
|
|
if (options.mode) {
|
|
|
|
args.mode = options.mode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
|
|
|
function mkdirSync(path, options) {
|
2022-08-11 09:56:56 -04:00
|
|
|
ops.op_mkdir_sync(mkdirArgs(path, options));
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function mkdir(
|
|
|
|
path,
|
|
|
|
options,
|
|
|
|
) {
|
2021-04-12 15:55:05 -04:00
|
|
|
await core.opAsync("op_mkdir_async", mkdirArgs(path, options));
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function readDirSync(path) {
|
2022-08-11 09:56:56 -04:00
|
|
|
return ops.op_read_dir_sync(pathFromURL(path))[
|
2021-07-03 11:17:23 -04:00
|
|
|
SymbolIterator
|
2020-07-19 13:49:44 -04:00
|
|
|
]();
|
|
|
|
}
|
|
|
|
|
|
|
|
function readDir(path) {
|
2021-04-12 15:55:05 -04:00
|
|
|
const array = core.opAsync(
|
2020-09-16 16:22:43 -04:00
|
|
|
"op_read_dir_async",
|
2021-04-05 12:40:24 -04:00
|
|
|
pathFromURL(path),
|
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
return {
|
2021-07-03 11:17:23 -04:00
|
|
|
async *[SymbolAsyncIterator]() {
|
2020-07-19 13:49:44 -04:00
|
|
|
yield* await array;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function readLinkSync(path) {
|
2022-08-11 09:56:56 -04:00
|
|
|
return ops.op_read_link_sync(pathFromURL(path));
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function readLink(path) {
|
2021-04-12 15:55:05 -04:00
|
|
|
return core.opAsync("op_read_link_async", pathFromURL(path));
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function realPathSync(path) {
|
2022-08-11 09:56:56 -04:00
|
|
|
return ops.op_realpath_sync(pathFromURL(path));
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function realPath(path) {
|
2021-05-17 00:31:21 -04:00
|
|
|
return core.opAsync("op_realpath_async", pathFromURL(path));
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function removeSync(
|
|
|
|
path,
|
|
|
|
options = {},
|
|
|
|
) {
|
2022-09-22 05:09:25 -04:00
|
|
|
ops.op_remove_sync(
|
|
|
|
pathFromURL(path),
|
|
|
|
!!options.recursive,
|
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function remove(
|
|
|
|
path,
|
|
|
|
options = {},
|
|
|
|
) {
|
2022-09-22 05:09:25 -04:00
|
|
|
await core.opAsync(
|
|
|
|
"op_remove_async",
|
|
|
|
pathFromURL(path),
|
|
|
|
!!options.recursive,
|
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function renameSync(oldpath, newpath) {
|
2022-09-22 05:09:25 -04:00
|
|
|
ops.op_rename_sync(
|
|
|
|
pathFromURL(oldpath),
|
|
|
|
pathFromURL(newpath),
|
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function rename(oldpath, newpath) {
|
2022-09-22 05:09:25 -04:00
|
|
|
await core.opAsync(
|
|
|
|
"op_rename_async",
|
|
|
|
pathFromURL(oldpath),
|
|
|
|
pathFromURL(newpath),
|
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
2022-09-22 05:09:25 -04:00
|
|
|
// Extract the FsStat object from the encoded buffer.
|
|
|
|
// See `runtime/ops/fs.rs` for the encoder.
|
|
|
|
//
|
|
|
|
// This is not a general purpose decoder. There are 4 types:
|
|
|
|
//
|
|
|
|
// 1. date
|
|
|
|
// offset += 4
|
|
|
|
// 1/0 | extra padding | high u32 | low u32
|
|
|
|
// if date[0] == 1, new Date(u64) else null
|
|
|
|
//
|
|
|
|
// 2. bool
|
|
|
|
// offset += 2
|
|
|
|
// 1/0 | extra padding
|
|
|
|
//
|
|
|
|
// 3. u64
|
|
|
|
// offset += 2
|
|
|
|
// high u32 | low u32
|
|
|
|
//
|
|
|
|
// 4. ?u64 converts a zero u64 value to JS null on Windows.
|
|
|
|
function createByteStruct(types) {
|
|
|
|
// types can be "date", "bool" or "u64".
|
|
|
|
// `?` prefix means optional on windows.
|
|
|
|
let offset = 0;
|
|
|
|
let str =
|
|
|
|
'const unix = Deno.build.os === "darwin" || Deno.build.os === "linux"; return {';
|
2022-12-19 21:37:50 -05:00
|
|
|
for (let [name, type] of new SafeArrayIterator(ObjectEntries(types))) {
|
2022-09-22 05:09:25 -04:00
|
|
|
const optional = type.startsWith("?");
|
|
|
|
if (optional) type = type.slice(1);
|
|
|
|
|
|
|
|
if (type == "u64") {
|
|
|
|
if (!optional) {
|
|
|
|
str += `${name}: view[${offset}] + view[${offset + 1}] * 2**32,`;
|
|
|
|
} else {
|
|
|
|
str += `${name}: (unix ? (view[${offset}] + view[${
|
|
|
|
offset + 1
|
|
|
|
}] * 2**32) : (view[${offset}] + view[${
|
|
|
|
offset + 1
|
|
|
|
}] * 2**32) || null),`;
|
|
|
|
}
|
|
|
|
} else if (type == "date") {
|
|
|
|
str += `${name}: view[${offset}] === 0 ? null : new Date(view[${
|
|
|
|
offset + 2
|
|
|
|
}] + view[${offset + 3}] * 2**32),`;
|
|
|
|
offset += 2;
|
|
|
|
} else {
|
|
|
|
str += `${name}: !!(view[${offset}] + view[${offset + 1}] * 2**32),`;
|
|
|
|
}
|
|
|
|
offset += 2;
|
|
|
|
}
|
|
|
|
str += "};";
|
|
|
|
// ...so you don't like eval huh? don't worry, it only executes during snapshot :)
|
|
|
|
return [new Function("view", str), new Uint32Array(offset)];
|
|
|
|
}
|
|
|
|
|
|
|
|
const [statStruct, statBuf] = createByteStruct({
|
|
|
|
isFile: "bool",
|
|
|
|
isDirectory: "bool",
|
|
|
|
isSymlink: "bool",
|
|
|
|
size: "u64",
|
|
|
|
mtime: "date",
|
|
|
|
atime: "date",
|
|
|
|
birthtime: "date",
|
|
|
|
dev: "?u64",
|
|
|
|
ino: "?u64",
|
|
|
|
mode: "?u64",
|
|
|
|
nlink: "?u64",
|
|
|
|
uid: "?u64",
|
|
|
|
gid: "?u64",
|
|
|
|
rdev: "?u64",
|
|
|
|
blksize: "?u64",
|
|
|
|
blocks: "?u64",
|
|
|
|
});
|
|
|
|
|
2020-07-19 13:49:44 -04:00
|
|
|
function parseFileInfo(response) {
|
|
|
|
const unix = build.os === "darwin" || build.os === "linux";
|
|
|
|
return {
|
|
|
|
isFile: response.isFile,
|
|
|
|
isDirectory: response.isDirectory,
|
|
|
|
isSymlink: response.isSymlink,
|
|
|
|
size: response.size,
|
2022-09-22 05:09:25 -04:00
|
|
|
mtime: response.mtimeSet !== null ? new Date(response.mtime) : null,
|
|
|
|
atime: response.atimeSet !== null ? new Date(response.atime) : null,
|
|
|
|
birthtime: response.birthtimeSet !== null
|
2020-07-19 13:49:44 -04:00
|
|
|
? new Date(response.birthtime)
|
|
|
|
: null,
|
|
|
|
// Only non-null if on Unix
|
|
|
|
dev: unix ? response.dev : null,
|
|
|
|
ino: unix ? response.ino : null,
|
|
|
|
mode: unix ? response.mode : null,
|
|
|
|
nlink: unix ? response.nlink : null,
|
|
|
|
uid: unix ? response.uid : null,
|
|
|
|
gid: unix ? response.gid : null,
|
|
|
|
rdev: unix ? response.rdev : null,
|
|
|
|
blksize: unix ? response.blksize : null,
|
|
|
|
blocks: unix ? response.blocks : null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function fstatSync(rid) {
|
2022-09-22 05:09:25 -04:00
|
|
|
ops.op_fstat_sync(rid, statBuf);
|
|
|
|
return statStruct(statBuf);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fstat(rid) {
|
2021-04-12 15:55:05 -04:00
|
|
|
return parseFileInfo(await core.opAsync("op_fstat_async", rid));
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function lstat(path) {
|
2021-04-12 15:55:05 -04:00
|
|
|
const res = await core.opAsync("op_stat_async", {
|
2020-07-19 13:49:44 -04:00
|
|
|
path: pathFromURL(path),
|
|
|
|
lstat: true,
|
|
|
|
});
|
|
|
|
return parseFileInfo(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
function lstatSync(path) {
|
2022-09-22 05:09:25 -04:00
|
|
|
ops.op_stat_sync(
|
|
|
|
pathFromURL(path),
|
|
|
|
true,
|
|
|
|
statBuf,
|
|
|
|
);
|
|
|
|
return statStruct(statBuf);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function stat(path) {
|
2021-04-12 15:55:05 -04:00
|
|
|
const res = await core.opAsync("op_stat_async", {
|
2020-07-19 13:49:44 -04:00
|
|
|
path: pathFromURL(path),
|
|
|
|
lstat: false,
|
|
|
|
});
|
|
|
|
return parseFileInfo(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
function statSync(path) {
|
2022-09-22 05:09:25 -04:00
|
|
|
ops.op_stat_sync(
|
|
|
|
pathFromURL(path),
|
|
|
|
false,
|
|
|
|
statBuf,
|
|
|
|
);
|
|
|
|
return statStruct(statBuf);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function coerceLen(len) {
|
|
|
|
if (len == null || len < 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ftruncateSync(rid, len) {
|
2022-09-22 05:09:25 -04:00
|
|
|
ops.op_ftruncate_sync(rid, coerceLen(len));
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function ftruncate(rid, len) {
|
2022-09-22 05:09:25 -04:00
|
|
|
await core.opAsync("op_ftruncate_async", rid, coerceLen(len));
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function truncateSync(path, len) {
|
2022-09-22 05:09:25 -04:00
|
|
|
ops.op_truncate_sync(path, coerceLen(len));
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function truncate(path, len) {
|
2022-09-22 05:09:25 -04:00
|
|
|
await core.opAsync("op_truncate_async", path, coerceLen(len));
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function umask(mask) {
|
2022-08-11 09:56:56 -04:00
|
|
|
return ops.op_umask(mask);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function linkSync(oldpath, newpath) {
|
2022-09-22 05:09:25 -04:00
|
|
|
ops.op_link_sync(oldpath, newpath);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function link(oldpath, newpath) {
|
2022-09-22 05:09:25 -04:00
|
|
|
await core.opAsync("op_link_async", oldpath, newpath);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
2020-09-01 10:03:07 -04:00
|
|
|
function toUnixTimeFromEpoch(value) {
|
2022-02-01 12:06:11 -05:00
|
|
|
if (ObjectPrototypeIsPrototypeOf(DatePrototype, value)) {
|
2020-09-01 10:03:07 -04:00
|
|
|
const time = value.valueOf();
|
2021-07-03 11:17:23 -04:00
|
|
|
const seconds = MathTrunc(time / 1e3);
|
|
|
|
const nanoseconds = MathTrunc(time - (seconds * 1e3)) * 1e6;
|
2020-09-01 10:03:07 -04:00
|
|
|
|
|
|
|
return [
|
|
|
|
seconds,
|
|
|
|
nanoseconds,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
const seconds = value;
|
|
|
|
const nanoseconds = 0;
|
|
|
|
|
|
|
|
return [
|
|
|
|
seconds,
|
|
|
|
nanoseconds,
|
|
|
|
];
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
2020-08-31 14:29:43 -04:00
|
|
|
function futimeSync(
|
|
|
|
rid,
|
|
|
|
atime,
|
|
|
|
mtime,
|
|
|
|
) {
|
2022-09-22 05:09:25 -04:00
|
|
|
const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime);
|
|
|
|
const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime);
|
|
|
|
ops.op_futime_sync(rid, atimeSec, atimeNsec, mtimeSec, mtimeNsec);
|
2020-08-31 14:29:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function futime(
|
|
|
|
rid,
|
|
|
|
atime,
|
|
|
|
mtime,
|
|
|
|
) {
|
2022-09-22 05:09:25 -04:00
|
|
|
const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime);
|
|
|
|
const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime);
|
|
|
|
await core.opAsync(
|
|
|
|
"op_futime_async",
|
2020-08-31 14:29:43 -04:00
|
|
|
rid,
|
2022-09-22 05:09:25 -04:00
|
|
|
atimeSec,
|
|
|
|
atimeNsec,
|
|
|
|
mtimeSec,
|
|
|
|
mtimeNsec,
|
|
|
|
);
|
2020-08-31 14:29:43 -04:00
|
|
|
}
|
|
|
|
|
2020-07-19 13:49:44 -04:00
|
|
|
function utimeSync(
|
|
|
|
path,
|
|
|
|
atime,
|
|
|
|
mtime,
|
|
|
|
) {
|
2022-09-22 05:09:25 -04:00
|
|
|
const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime);
|
|
|
|
const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime);
|
|
|
|
ops.op_utime_sync(
|
|
|
|
pathFromURL(path),
|
|
|
|
atimeSec,
|
|
|
|
atimeNsec,
|
|
|
|
mtimeSec,
|
|
|
|
mtimeNsec,
|
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function utime(
|
|
|
|
path,
|
|
|
|
atime,
|
|
|
|
mtime,
|
|
|
|
) {
|
2022-09-22 05:09:25 -04:00
|
|
|
const [atimeSec, atimeNsec] = toUnixTimeFromEpoch(atime);
|
|
|
|
const [mtimeSec, mtimeNsec] = toUnixTimeFromEpoch(mtime);
|
|
|
|
await core.opAsync(
|
|
|
|
"op_utime_async",
|
|
|
|
pathFromURL(path),
|
|
|
|
atimeSec,
|
|
|
|
atimeNsec,
|
|
|
|
mtimeSec,
|
|
|
|
mtimeNsec,
|
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function symlinkSync(
|
|
|
|
oldpath,
|
|
|
|
newpath,
|
|
|
|
options,
|
|
|
|
) {
|
2022-09-22 05:09:25 -04:00
|
|
|
ops.op_symlink_sync(
|
|
|
|
pathFromURL(oldpath),
|
|
|
|
pathFromURL(newpath),
|
|
|
|
options?.type,
|
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function symlink(
|
|
|
|
oldpath,
|
|
|
|
newpath,
|
|
|
|
options,
|
|
|
|
) {
|
2022-09-22 05:09:25 -04:00
|
|
|
await core.opAsync(
|
|
|
|
"op_symlink_async",
|
|
|
|
pathFromURL(oldpath),
|
|
|
|
pathFromURL(newpath),
|
|
|
|
options?.type,
|
|
|
|
);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function fdatasyncSync(rid) {
|
2022-08-11 09:56:56 -04:00
|
|
|
ops.op_fdatasync_sync(rid);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fdatasync(rid) {
|
2021-04-12 15:55:05 -04:00
|
|
|
await core.opAsync("op_fdatasync_async", rid);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function fsyncSync(rid) {
|
2022-08-11 09:56:56 -04:00
|
|
|
ops.op_fsync_sync(rid);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fsync(rid) {
|
2021-04-12 15:55:05 -04:00
|
|
|
await core.opAsync("op_fsync_async", rid);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
2021-08-24 09:21:31 -04:00
|
|
|
function flockSync(rid, exclusive) {
|
2022-08-11 09:56:56 -04:00
|
|
|
ops.op_flock_sync(rid, exclusive === true);
|
2021-08-24 09:21:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function flock(rid, exclusive) {
|
|
|
|
await core.opAsync("op_flock_async", rid, exclusive === true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function funlockSync(rid) {
|
2022-08-11 09:56:56 -04:00
|
|
|
ops.op_funlock_sync(rid);
|
2021-08-24 09:21:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function funlock(rid) {
|
|
|
|
await core.opAsync("op_funlock_async", rid);
|
|
|
|
}
|
|
|
|
|
2020-07-19 13:49:44 -04:00
|
|
|
window.__bootstrap.fs = {
|
|
|
|
cwd,
|
|
|
|
chdir,
|
|
|
|
chmodSync,
|
|
|
|
chmod,
|
|
|
|
chown,
|
|
|
|
chownSync,
|
|
|
|
copyFile,
|
|
|
|
copyFileSync,
|
|
|
|
makeTempFile,
|
|
|
|
makeTempDir,
|
|
|
|
makeTempFileSync,
|
|
|
|
makeTempDirSync,
|
|
|
|
mkdir,
|
|
|
|
mkdirSync,
|
|
|
|
readDir,
|
|
|
|
readDirSync,
|
|
|
|
readLinkSync,
|
|
|
|
readLink,
|
|
|
|
realPathSync,
|
|
|
|
realPath,
|
|
|
|
remove,
|
|
|
|
removeSync,
|
|
|
|
renameSync,
|
|
|
|
rename,
|
|
|
|
lstat,
|
|
|
|
lstatSync,
|
|
|
|
stat,
|
|
|
|
statSync,
|
|
|
|
ftruncate,
|
|
|
|
ftruncateSync,
|
|
|
|
truncate,
|
|
|
|
truncateSync,
|
|
|
|
umask,
|
|
|
|
link,
|
|
|
|
linkSync,
|
2021-04-12 07:33:05 -04:00
|
|
|
fstatSync,
|
|
|
|
fstat,
|
2020-08-31 14:29:43 -04:00
|
|
|
futime,
|
|
|
|
futimeSync,
|
2020-07-19 13:49:44 -04:00
|
|
|
utime,
|
|
|
|
utimeSync,
|
|
|
|
symlink,
|
|
|
|
symlinkSync,
|
|
|
|
fdatasync,
|
|
|
|
fdatasyncSync,
|
|
|
|
fsync,
|
|
|
|
fsyncSync,
|
2021-08-24 09:21:31 -04:00
|
|
|
flock,
|
|
|
|
flockSync,
|
|
|
|
funlock,
|
|
|
|
funlockSync,
|
2020-07-19 13:49:44 -04:00
|
|
|
};
|
|
|
|
})(this);
|