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