Copying an std.stdio.File into another one

0xEAB desisma at
Mon May 21 11:50:18 UTC 2018

What's the correct way to copy a `File` into another one in D?

If `LockingTextReader` wasn't undocumented, I'd have gone for 
that approach:

> import std.algorithm.mutation : copy;
> import std.stdio : File, LockingTextReader;
> void main()
> {
>     auto a = File("a.txt", "r");
>     auto b = File("b.txt", "w");
>     a.LockingTextReader.copy(b.lockingTextWriter);
> }

Although the example code suggest otherwise, I'm not talking 
about copying actual files on disk. In such a case I'd just use 
`std.file.copy` ;)
So, just imagine `a` were `stdout` of process pipe.

Kind regards,

More information about the Digitalmars-d-learn mailing list