It would be nice to have a file similar to stdout or stderr that does nothing, say, stdnull.
It is useful when one needs to suppress some output (e.g. when --silent flag is sent to the program).
On Linux the following code does the trick:
--------------------
File stdnull;
static this()
{
version(Posix)
{
stdnull = File("/dev/null", "w");
}
}
--------------------
What about other systems?
I also needed something like this a while back (also for input, though), so I agree that having it in Phobos would be nice.
(In reply to Maksim Zholudev from comment #0)
> What about other systems?
NUL should do the trick on Windows, I think.
Comment #3 by robert.schadek — 2024-12-01T16:21:17Z