Implement mkdirSync

This commit is contained in:
Sajjad Hashemian 2018-08-26 10:56:30 +04:30 committed by Ryan Dahl
parent dff909ef6c
commit b2b4299e3b
5 changed files with 73 additions and 0 deletions

View file

@ -104,6 +104,25 @@ export function makeTempDirSync({
return path!;
}
// mkdir creates a new directory with the specified name
// and permission bits (before umask).
export function mkdirSync(path: string, mode = 0o777): void {
/* Ideally we could write:
const res = send({
command: fbs.Command.MKDIR_SYNC,
mkdirSyncPath: path,
mkdirSyncMode: mode,
});
*/
const builder = new flatbuffers.Builder();
const path_ = builder.createString(path);
fbs.MkdirSync.startMkdirSync(builder);
fbs.MkdirSync.addPath(builder, path_);
fbs.MkdirSync.addMode(builder, mode);
const msg = fbs.MkdirSync.endMkdirSync(builder);
send(builder, fbs.Any.MkdirSync, msg);
}
export function readFileSync(filename: string): Uint8Array {
/* Ideally we could write
const res = send({