2020-04-12 14:34:16 -04:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-07-08 05:26:39 -04:00
|
|
|
import type { CallbackWithError } from "./_fs_common.ts";
|
2020-05-03 15:14:38 -04:00
|
|
|
import { fromFileUrl } from "../path.ts";
|
2020-04-12 14:34:16 -04:00
|
|
|
|
|
|
|
export function copyFile(
|
2020-05-03 15:14:38 -04:00
|
|
|
source: string | URL,
|
2020-04-12 14:34:16 -04:00
|
|
|
destination: string,
|
2020-07-14 15:24:17 -04:00
|
|
|
callback: CallbackWithError,
|
2020-04-12 14:34:16 -04:00
|
|
|
): void {
|
2020-05-03 15:14:38 -04:00
|
|
|
source = source instanceof URL ? fromFileUrl(source) : source;
|
|
|
|
|
2020-04-20 05:29:37 -04:00
|
|
|
Deno.copyFile(source, destination)
|
|
|
|
.then(() => callback())
|
|
|
|
.catch(callback);
|
2020-04-12 14:34:16 -04:00
|
|
|
}
|
|
|
|
|
2020-05-03 15:14:38 -04:00
|
|
|
export function copyFileSync(source: string | URL, destination: string): void {
|
|
|
|
source = source instanceof URL ? fromFileUrl(source) : source;
|
2020-04-29 21:36:44 -04:00
|
|
|
Deno.copyFileSync(source, destination);
|
2020-04-12 14:34:16 -04:00
|
|
|
}
|