Writing to two files at once

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 21 13:57:12 PDT 2015


On Thursday, 21 May 2015 at 20:15:29 UTC, wobbles wrote:
> On Thursday, 21 May 2015 at 20:06:08 UTC, wobbles wrote:
>> I would like to write to two files at once.
>>
>> If user specifies verbose flag, output should write to both 
>> stdout and the programs standard output file.
>>
>> Any ideas?
>
> I should add, I'm using a library that already writes it's 
> output to a std.stdout.File that I can provide it, so my 
> thinking is I need a std.stdout.File that points at both stdout 
> and some arbitrary file location.
>
> Tricky I think...

If it is hardcoded to take a File (I.e. it's not a template 
parameter), then your options are: modify the library, modify 
phobos or use the OS to do the duplication. On *nix you should be 
able to do it quite easily, don't know about windows.


More information about the Digitalmars-d-learn mailing list