gitea push

This commit is contained in:
2026-05-09 12:19:29 -06:00
parent 06113c95b8
commit 429461e985
1481 changed files with 74306 additions and 52475 deletions
+22 -2
View File
@@ -3,6 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.WASI = void 0;
const webassembly_1 = require("../webassembly");
const path_1 = require("./path");
// Linux fcntl flag bits ↔ Windows libuv flag bits. `pathOpen()` builds
// `flagsRes` using Linux constants (O_CREAT=0x40, O_EXCL=0x80,
// O_APPEND=0x400). Windows libuv expects different bits (O_CREAT=0x100,
// O_EXCL=0x400, O_APPEND=0x8). Without translation,
// `fs.openSync(path, 0x241 /* L:WRONLY|CREAT|TRUNC */)` is rejected
// with EINVAL because Linux's 0x40 happens to mean O_TEMPORARY on
// Windows — and O_TEMPORARY without O_CREAT is invalid.
const _isWin32Flags = typeof process !== 'undefined' && process.platform === 'win32';
function _toWinOpenFlags(f) {
let r = f & 3; // RDONLY/WRONLY/RDWR — same on both
if ((f & 0x40) !== 0)
r |= 0x100; // O_CREAT: Linux 0x40 -> Windows 0x100
if ((f & 0x80) !== 0)
r |= 0x400; // O_EXCL: Linux 0x80 -> Windows 0x400
if ((f & 0x200) !== 0)
r |= 0x200; // O_TRUNC: same value on both
if ((f & 0x400) !== 0)
r |= 0x8; // O_APPEND: Linux 0x400 -> Windows 0x8
return r;
}
const types_1 = require("./types");
const fd_1 = require("./fd");
const error_1 = require("./error");
@@ -1266,7 +1286,7 @@ class WASI {
const pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
const fs = getFs(this);
const resolved_path = resolvePathSync(fs, fileDescriptor, pathString, dirflags);
const r = fs.openSync(resolved_path, flagsRes, 0o666);
const r = fs.openSync(resolved_path, _isWin32Flags ? _toWinOpenFlags(flagsRes) : flagsRes, 0o666);
const filetype = wasi.fds.getFileTypeByFd(r);
if ((filetype !== types_1.WasiFileType.DIRECTORY) &&
((o_flags & types_1.WasiFileControlFlag.O_DIRECTORY) !== 0 ||
@@ -1302,7 +1322,7 @@ class WASI {
const pathString = decoder.decode((0, util_1.unsharedSlice)(HEAPU8, path, path + path_len));
const fs = getFs(this);
const resolved_path = await resolvePathAsync(fs, fileDescriptor, pathString, dirflags);
const r = await fs.promises.open(resolved_path, flagsRes, 0o666);
const r = await fs.promises.open(resolved_path, _isWin32Flags ? _toWinOpenFlags(flagsRes) : flagsRes, 0o666);
const filetype = await wasi.fds.getFileTypeByFd(r);
if ((o_flags & types_1.WasiFileControlFlag.O_DIRECTORY) !== 0 && filetype !== types_1.WasiFileType.DIRECTORY) {
return types_1.WasiErrno.ENOTDIR;