2019-01-01 19:58:40 -05:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2019-08-26 16:18:42 +02:00
|
|
|
import { sendSync, sendAsync } from "./dispatch_json";
|
|
|
|
import * as dispatch from "./dispatch";
|
2019-03-10 04:30:38 +11:00
|
|
|
|
2018-10-15 07:29:50 +11:00
|
|
|
/** Copies the contents of a file to another by name synchronously.
|
2018-09-30 15:06:41 -07:00
|
|
|
* Creates a new file if target does not exists, and if target exists,
|
|
|
|
* overwrites original content of the target file.
|
2018-10-15 07:29:50 +11:00
|
|
|
*
|
2018-09-30 15:06:41 -07:00
|
|
|
* It would also copy the permission of the original file
|
|
|
|
* to the destination.
|
|
|
|
*
|
2019-02-13 02:08:56 +11:00
|
|
|
* Deno.copyFileSync("from.txt", "to.txt");
|
2018-09-30 15:06:41 -07:00
|
|
|
*/
|
|
|
|
export function copyFileSync(from: string, to: string): void {
|
2019-08-26 16:18:42 +02:00
|
|
|
sendSync(dispatch.OP_COPY_FILE, { from, to });
|
2018-09-30 15:06:41 -07:00
|
|
|
}
|
|
|
|
|
2018-10-15 07:29:50 +11:00
|
|
|
/** Copies the contents of a file to another by name.
|
|
|
|
*
|
2018-09-30 15:06:41 -07:00
|
|
|
* Creates a new file if target does not exists, and if target exists,
|
|
|
|
* overwrites original content of the target file.
|
2018-10-15 07:29:50 +11:00
|
|
|
*
|
2018-09-30 15:06:41 -07:00
|
|
|
* It would also copy the permission of the original file
|
|
|
|
* to the destination.
|
|
|
|
*
|
2019-02-13 02:08:56 +11:00
|
|
|
* await Deno.copyFile("from.txt", "to.txt");
|
2018-09-30 15:06:41 -07:00
|
|
|
*/
|
|
|
|
export async function copyFile(from: string, to: string): Promise<void> {
|
2019-08-26 16:18:42 +02:00
|
|
|
await sendAsync(dispatch.OP_COPY_FILE, { from, to });
|
2018-09-30 15:06:41 -07:00
|
|
|
}
|