mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
c9614d86c1
Fixes some sed errors introduced in c43cfe. Unfortunately moving libdeno required splitting build.rs into two parts, one for cli and one for core. I've also removed the arm64 build - it's complicating things at this re-org and we're not even testing it. I need to swing back to it and get tools/test.py running for it.
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
|
import * as msg from "gen/cli/msg_generated";
|
|
import * as flatbuffers from "./flatbuffers";
|
|
import * as dispatch from "./dispatch";
|
|
|
|
function req(
|
|
from: string,
|
|
to: string
|
|
): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
|
const builder = flatbuffers.createBuilder();
|
|
const from_ = builder.createString(from);
|
|
const to_ = builder.createString(to);
|
|
msg.CopyFile.startCopyFile(builder);
|
|
msg.CopyFile.addFrom(builder, from_);
|
|
msg.CopyFile.addTo(builder, to_);
|
|
const inner = msg.CopyFile.endCopyFile(builder);
|
|
return [builder, msg.Any.CopyFile, inner];
|
|
}
|
|
|
|
/** Copies the contents of a file to another by name synchronously.
|
|
* Creates a new file if target does not exists, and if target exists,
|
|
* overwrites original content of the target file.
|
|
*
|
|
* It would also copy the permission of the original file
|
|
* to the destination.
|
|
*
|
|
* Deno.copyFileSync("from.txt", "to.txt");
|
|
*/
|
|
export function copyFileSync(from: string, to: string): void {
|
|
dispatch.sendSync(...req(from, to));
|
|
}
|
|
|
|
/** Copies the contents of a file to another by name.
|
|
*
|
|
* Creates a new file if target does not exists, and if target exists,
|
|
* overwrites original content of the target file.
|
|
*
|
|
* It would also copy the permission of the original file
|
|
* to the destination.
|
|
*
|
|
* await Deno.copyFile("from.txt", "to.txt");
|
|
*/
|
|
export async function copyFile(from: string, to: string): Promise<void> {
|
|
await dispatch.sendAsync(...req(from, to));
|
|
}
|