digitalmars.D.learn - Writing to two files at once
- wobbles (4/4) May 21 2015 I would like to write to two files at once.
- wobbles (6/10) May 21 2015 I should add, I'm using a library that already writes it's output
- wobbles (6/18) May 21 2015 What I ended up doing was creating an OutputRange that contains
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (4/7) May 21 2015 Just like MultiFile example here: :)
- wobbles (14/22) May 21 2015 Yeah!
- John Colvin (5/17) May 21 2015 If it is hardcoded to take a File (I.e. it's not a template
- Cassio Butrico (2/2) May 21 2015 If I understand right you want to redirect the output to a file
- wobbles (5/7) May 21 2015 I think by video printer you mean the console?
- Cassio Butrico (2/9) May 21 2015 You're right, Ali 's book is of great help for all
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?
May 21 2015
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...
May 21 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:What I ended up doing was creating an OutputRange that contains the files I want to write to. On OutputRange.put I simply print to print to all the files. Means I had to edit the underlying library, but that's OK as I own it, and this seems more robust anyway :)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...
May 21 2015
On 05/21/2015 01:56 PM, wobbles wrote:What I ended up doing was creating an OutputRange that contains the files I want to write to. On OutputRange.put I simply print to print to all the files.Just like MultiFile example here: :) http://ddili.org/ders/d.en/ranges.html#ix_ranges.OutputRange Ali
May 21 2015
On Thursday, 21 May 2015 at 21:02:42 UTC, Ali Çehreli wrote:On 05/21/2015 01:56 PM, wobbles wrote:Yeah! This is my implementation: public struct OutputSink{ File[] files; property void addFile(File f){ files ~= f; } property File[] file(){ return files; } void put(Args...)(string fmt, Args args){ foreach(file; files) file.writefln(fmt, args); } } I'll remember to look in your book next time I need something simple :)What I ended up doing was creating an OutputRange that contains the files I want to write to. On OutputRange.put I simply print to print to all the files.Just like MultiFile example here: :) http://ddili.org/ders/d.en/ranges.html#ix_ranges.OutputRange Ali
May 21 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: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.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...
May 21 2015
If I understand right you want to redirect the output to a file by a flag , another file type , video printer is it?
May 21 2015
On Thursday, 21 May 2015 at 21:00:15 UTC, Cassio Butrico wrote:If I understand right you want to redirect the output to a file by a flag , another file type , video printer is it?I think by video printer you mean the console? If so, yes. I believe I've solved it anyway, see Ali and my answer above. Thanks!
May 21 2015
On Thursday, 21 May 2015 at 21:16:59 UTC, wobbles wrote:On Thursday, 21 May 2015 at 21:00:15 UTC, Cassio Butrico wrote:You're right, Ali 's book is of great help for allIf I understand right you want to redirect the output to a file by a flag , another file type , video printer is it?I think by video printer you mean the console? If so, yes. I believe I've solved it anyway, see Ali and my answer above. Thanks!
May 21 2015