Thread overview
Output range for file?
Jan 24, 2016
Tofu Ninja
Jan 24, 2016
H. S. Teoh
Jan 24, 2016
Tofu Ninja
January 24, 2016
I tried looking for this in phobos but cant seem to find it which is really annoying. For my uses this works:

struct fileOutRange
{
	File f;
	void put(ubyte[] a)
	{
		f.rawWrite(a);
	}
}

But was just wondering if there was a real output range for files somewhere in phobos that I just cant seem to find.
January 24, 2016
On Sun, Jan 24, 2016 at 12:38:22PM +0000, Tofu Ninja via Digitalmars-d-learn wrote:
> I tried looking for this in phobos but cant seem to find it which is really annoying. For my uses this works:

What kind of data do you need to write to file?  If it's textual data, use File.lockingTextWriter, which is an output range.

If it's binary data, you'll probably have to roll your own; there's a Phobos PR right now that implements File.lockingBinaryWriter, but it's not quite ready for merging yet.


T

-- 
Real men don't take backups. They put their source on a public FTP-server and let the world mirror it. -- Linus Torvalds
January 24, 2016
On Sunday, 24 January 2016 at 15:08:33 UTC, H. S. Teoh wrote:
> On Sun, Jan 24, 2016 at 12:38:22PM +0000, Tofu Ninja via Digitalmars-d-learn wrote:
>> I tried looking for this in phobos but cant seem to find it which is really annoying. For my uses this works:
>
> What kind of data do you need to write to file?  If it's textual data, use File.lockingTextWriter, which is an output range.
>
> If it's binary data, you'll probably have to roll your own; there's a Phobos PR right now that implements File.lockingBinaryWriter, but it's not quite ready for merging yet.
>
>
> T

I am writing out binary data, so I guess I will just keep using what I am using.