diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-08-26 16:18:42 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-08-26 10:18:42 -0400 |
commit | a6f6209f5277f2737bc67efad5c91ab168aff6b5 (patch) | |
tree | 88e8449e61e09cf5037def8d723ec43654d31b06 /js/dir.ts | |
parent | 520f9631e09aa720fd8c03513ee8ea967f5ed4b2 (diff) |
port fs ops to JSON (#2812)
Diffstat (limited to 'js/dir.ts')
-rw-r--r-- | js/dir.ts | 19 |
1 files changed, 4 insertions, 15 deletions
@@ -1,6 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { assert } from "./util"; -import { sendSync, flatbuffers, msg } from "./dispatch_flatbuffers"; +import { sendSync } from "./dispatch_json"; +import * as dispatch from "./dispatch"; /** * `cwd()` Return a string representing the current working directory. @@ -10,15 +10,7 @@ import { sendSync, flatbuffers, msg } from "./dispatch_flatbuffers"; * throws `NotFound` exception if directory not available */ export function cwd(): string { - const builder = flatbuffers.createBuilder(); - msg.Cwd.startCwd(builder); - const inner = msg.Cwd.endCwd(builder); - const baseRes = sendSync(builder, msg.Any.Cwd, inner); - assert(baseRes != null); - assert(msg.Any.CwdRes === baseRes!.innerType()); - const res = new msg.CwdRes(); - assert(baseRes!.inner(res) != null); - return res.cwd()!; + return sendSync(dispatch.OP_CWD); } /** @@ -26,8 +18,5 @@ export function cwd(): string { * throws `NotFound` exception if directory not available */ export function chdir(directory: string): void { - const builder = flatbuffers.createBuilder(); - const directory_ = builder.createString(directory); - const inner = msg.Chdir.createChdir(builder, directory_); - sendSync(builder, msg.Any.Chdir, inner); + sendSync(dispatch.OP_CHDIR, { directory }); } |