mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
31 lines
1,016 B
TypeScript
31 lines
1,016 B
TypeScript
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
|
import * as msg from "gen/cli/msg_generated";
|
|
import * as flatbuffers from "./flatbuffers";
|
|
import * as dispatch from "./dispatch";
|
|
|
|
function req(
|
|
path: string,
|
|
mode: number
|
|
): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
|
const builder = flatbuffers.createBuilder();
|
|
const path_ = builder.createString(path);
|
|
const inner = msg.Chmod.createChmod(builder, path_, mode);
|
|
return [builder, msg.Any.Chmod, inner];
|
|
}
|
|
|
|
/** Changes the permission of a specific file/directory of specified path
|
|
* synchronously.
|
|
*
|
|
* Deno.chmodSync("/path/to/file", 0o666);
|
|
*/
|
|
export function chmodSync(path: string, mode: number): void {
|
|
dispatch.sendSync(...req(path, mode));
|
|
}
|
|
|
|
/** Changes the permission of a specific file/directory of specified path.
|
|
*
|
|
* await Deno.chmod("/path/to/file", 0o666);
|
|
*/
|
|
export async function chmod(path: string, mode: number): Promise<void> {
|
|
await dispatch.sendAsync(...req(path, mode));
|
|
}
|