mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 12:49:10 +00:00

Some checks failed
ci / pre-build (push) Has been cancelled
ci / test debug macos-x86_64 (push) Has been cancelled
ci / test release macos-x86_64 (push) Has been cancelled
ci / test debug windows-x86_64 (push) Has been cancelled
ci / test release windows-x86_64 (push) Has been cancelled
ci / test debug linux-aarch64 (push) Has been cancelled
ci / test release linux-aarch64 (push) Has been cancelled
ci / test debug macos-aarch64 (push) Has been cancelled
ci / test release macos-aarch64 (push) Has been cancelled
ci / bench release linux-x86_64 (push) Has been cancelled
ci / lint debug linux-x86_64 (push) Has been cancelled
ci / lint debug macos-x86_64 (push) Has been cancelled
ci / lint debug windows-x86_64 (push) Has been cancelled
ci / test debug linux-x86_64 (push) Has been cancelled
ci / test release linux-x86_64 (push) Has been cancelled
ci / build wasm32 (push) Has been cancelled
ci / publish canary (push) Has been cancelled
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
|
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
|
// deno-lint-ignore-file prefer-primordials
|
|
|
|
import {
|
|
type CallbackWithError,
|
|
makeCallback,
|
|
} from "ext:deno_node/_fs/_fs_common.ts";
|
|
import { kMaxUserId } from "ext:deno_node/internal/fs/utils.mjs";
|
|
import { validateInteger } from "ext:deno_node/internal/validators.mjs";
|
|
import { op_fs_fchown_async, op_fs_fchown_sync } from "ext:core/ops";
|
|
|
|
/**
|
|
* Changes the owner and group of a file.
|
|
*/
|
|
export function fchown(
|
|
fd: number,
|
|
uid: number,
|
|
gid: number,
|
|
callback: CallbackWithError,
|
|
) {
|
|
validateInteger(fd, "fd", 0, 2147483647);
|
|
validateInteger(uid, "uid", -1, kMaxUserId);
|
|
validateInteger(gid, "gid", -1, kMaxUserId);
|
|
callback = makeCallback(callback);
|
|
|
|
op_fs_fchown_async(fd, uid, gid).then(
|
|
() => callback(null),
|
|
callback,
|
|
);
|
|
}
|
|
/**
|
|
* Changes the owner and group of a file.
|
|
*/
|
|
export function fchownSync(
|
|
fd: number,
|
|
uid: number,
|
|
gid: number,
|
|
) {
|
|
validateInteger(fd, "fd", 0, 2147483647);
|
|
validateInteger(uid, "uid", -1, kMaxUserId);
|
|
validateInteger(gid, "gid", -1, kMaxUserId);
|
|
|
|
op_fs_fchown_sync(fd, uid, gid);
|
|
}
|