Skip to content

chown ​

Changes the owner and group of a file or directory. On non-Unix platforms, this returns Err with code ERR_FS_CHOWN_FAILED.

Signaturechown(path: string, uid: u32, gid: u32): Result<void, FsError>

Parameters ​

  • path, the file path to change.
  • uid, the new user ID.
  • gid, the new group ID.

Example ​

tyrus
import { FsError, chown } from "tyrus:fs";

// chown requires appropriate privileges
match (chown("./file.txt", 1000, 1000)) {
    Ok(_) => { print("ownership updated"); } // ownership updated
    Err(error) => { printError(error.code); } // ERR_FS_CHOWN_FAILED
}