summaryrefslogtreecommitdiff
path: root/js/symlink.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/symlink.ts')
-rw-r--r--js/symlink.ts28
1 files changed, 10 insertions, 18 deletions
diff --git a/js/symlink.ts b/js/symlink.ts
index 40551e9f8..6fd2e90a5 100644
--- a/js/symlink.ts
+++ b/js/symlink.ts
@@ -1,23 +1,9 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers";
+import { sendSync, sendAsync } from "./dispatch_json";
+import * as dispatch from "./dispatch";
import * as util from "./util";
import { platform } from "./build";
-function req(
- oldname: string,
- newname: string,
- type?: string
-): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
- if (platform.os === "win" && type) {
- return util.notImplemented();
- }
- const builder = flatbuffers.createBuilder();
- const oldname_ = builder.createString(oldname);
- const newname_ = builder.createString(newname);
- const inner = msg.Symlink.createSymlink(builder, oldname_, newname_);
- return [builder, msg.Any.Symlink, inner];
-}
-
/** Synchronously creates `newname` as a symbolic link to `oldname`. The type
* argument can be set to `dir` or `file` and is only available on Windows
* (ignored on other platforms).
@@ -29,7 +15,10 @@ export function symlinkSync(
newname: string,
type?: string
): void {
- sendSync(...req(oldname, newname, type));
+ if (platform.os === "win" && type) {
+ return util.notImplemented();
+ }
+ sendSync(dispatch.OP_SYMLINK, { oldname, newname });
}
/** Creates `newname` as a symbolic link to `oldname`. The type argument can be
@@ -43,5 +32,8 @@ export async function symlink(
newname: string,
type?: string
): Promise<void> {
- await sendAsync(...req(oldname, newname, type));
+ if (platform.os === "win" && type) {
+ return util.notImplemented();
+ }
+ await sendAsync(dispatch.OP_SYMLINK, { oldname, newname });
}