deno/ext/node/polyfills/_fs/_fs_fchmod.ts
Daniel Osvaldo R 0f0220e461
Some checks are pending
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
fix(ext/node): add fchmod and fchmodSync (#29791)
This PR implements `node:fs` `fchmod` and `fchmodSync`.

Towards https://github.com/denoland/deno/issues/27664 .
2025-06-18 12:48:14 +02:00

36 lines
895 B
TypeScript

// Copyright 2018-2025 the Deno authors. MIT license.
import {
type CallbackWithError,
makeCallback,
} from "ext:deno_node/_fs/_fs_common.ts";
import {
parseFileMode,
validateInteger,
} from "ext:deno_node/internal/validators.mjs";
import { op_fs_fchmod_async, op_fs_fchmod_sync } from "ext:core/ops";
import { primordials } from "ext:core/mod.js";
const { PromisePrototypeThen } = primordials;
export function fchmod(
fd: number,
mode: string | number,
callback: CallbackWithError,
) {
validateInteger(fd, "fd", 0, 2147483647);
mode = parseFileMode(mode, "mode");
callback = makeCallback(callback);
PromisePrototypeThen(
op_fs_fchmod_async(fd, mode),
() => callback(null),
callback,
);
}
export function fchmodSync(fd: number, mode: string | number) {
validateInteger(fd, "fd", 0, 2147483647);
op_fs_fchmod_sync(fd, parseFileMode(mode, "mode"));
}