Skip to content

chmod ​

Cambia los permisos de un archivo o directorio. El parámetro mode recibe un valor del enum FileMode. En plataformas que no son Unix, devuelve Err con el código ERR_FS_CHMOD_FAILED, porque los bits de permisos POSIX no son compatibles.

Firmachmod(path: string, mode: FileMode): Result<void, FsError>

Miembros de FileMode ​

MiembroValorOctal
Read2560o400
Write1280o200
Execute640o100
OwnerRead2560o400
OwnerWrite1280o200
OwnerExecute640o100
GroupRead320o040
GroupWrite160o020
GroupExecute80o010
OtherRead40o004
OtherWrite20o002
OtherExecute10o001
AllRead2920o444
AllWrite1460o222
AllExecute730o111
FullOwner4480o700
FullGroup560o070
FullOther70o007
Full5110o777

Ejemplo ​

tyrus
import { FsError, chmod, FileMode } from "tyrus:fs";

match (chmod("./file.txt", FileMode.AllRead)) {
    Ok(_) => { print("permissions updated"); } // permissions updated
    Err(error) => { printError(error.code); } // ERR_FS_CHMOD_FAILED
}
match (chmod("./file.txt", FileMode.FullOwner)) {
    Ok(_) => { print("permissions updated"); } // permissions updated
    Err(error) => { printError(error.code); } // ERR_FS_CHMOD_FAILED
}