2020-04-12 14:34:16 -04:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
|
|
|
import { 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,
|
|
|
|
callback: CallbackWithError
|
|
|
|
): 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
|
|
|
}
|