summaryrefslogtreecommitdiff
path: root/js/rename.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-08-26 16:18:42 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-08-26 10:18:42 -0400
commita6f6209f5277f2737bc67efad5c91ab168aff6b5 (patch)
tree88e8449e61e09cf5037def8d723ec43654d31b06 /js/rename.ts
parent520f9631e09aa720fd8c03513ee8ea967f5ed4b2 (diff)
port fs ops to JSON (#2812)
Diffstat (limited to 'js/rename.ts')
-rw-r--r--js/rename.ts18
1 files changed, 4 insertions, 14 deletions
diff --git a/js/rename.ts b/js/rename.ts
index 31f480d0e..80794747d 100644
--- a/js/rename.ts
+++ b/js/rename.ts
@@ -1,16 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
-
-function req(
- oldpath: string,
- newpath: string
-): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
- const builder = flatbuffers.createBuilder();
- const oldpath_ = builder.createString(oldpath);
- const newpath_ = builder.createString(newpath);
- const inner = msg.Rename.createRename(builder, oldpath_, newpath_);
- return [builder, msg.Any.Rename, inner];
-}
+import { sendSync, sendAsync } from "./dispatch_json";
+import * as dispatch from "./dispatch";
/** Synchronously renames (moves) `oldpath` to `newpath`. If `newpath` already
* exists and is not a directory, `renameSync()` replaces it. OS-specific
@@ -20,7 +10,7 @@ function req(
* Deno.renameSync("old/path", "new/path");
*/
export function renameSync(oldpath: string, newpath: string): void {
- sendSync(...req(oldpath, newpath));
+ sendSync(dispatch.OP_RENAME, { oldpath, newpath });
}
/** Renames (moves) `oldpath` to `newpath`. If `newpath` already exists and is
@@ -30,5 +20,5 @@ export function renameSync(oldpath: string, newpath: string): void {
* await Deno.rename("old/path", "new/path");
*/
export async function rename(oldpath: string, newpath: string): Promise<void> {
- await sendAsync(...req(oldpath, newpath));
+ await sendAsync(dispatch.OP_RENAME, { oldpath, newpath });
}