summaryrefslogtreecommitdiff
path: root/cli/js/ops/fs/copy_file.ts
blob: 6bbb3f599467aa17e8e9b4f080a4229dae805519 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "../dispatch_json.ts";
import { pathFromURL } from "../../util.ts";

export function copyFileSync(
  fromPath: string | URL,
  toPath: string | URL
): void {
  fromPath = pathFromURL(fromPath);
  toPath = pathFromURL(toPath);

  sendSync("op_copy_file", { from: fromPath, to: toPath });
}

export async function copyFile(
  fromPath: string | URL,
  toPath: string | URL
): Promise<void> {
  fromPath = pathFromURL(fromPath);
  toPath = pathFromURL(toPath);

  await sendAsync("op_copy_file", { from: fromPath, to: toPath });
}