On Monday, 3 September 2018 at 06:25:23 UTC, bauss wrote:
On Monday, 3 September 2018 at 03:19:39 UTC, Neia Neutuladh
wrote:
On Monday, 3 September 2018 at 03:04:57 UTC, Chris Katko wrote:
This should be simple? All I want to do is load an entire
file, and access individual bytes. The entire thing. I don't
want to have know the file size before hand, or "guess" and
have a "maximum size" buffer.
So far, all google searches for "dlang binary file read" end
up not working for me.
Thank you.
http://dpldocs.info/experimental-docs/std.file.read.1.html
import std.file : read;
auto bytes = read("filename");
This gives you a void[], which you can cast to ubyte[] or
char[] or whatever you need.
Or he could do readText() which returns a string, which in turn
will give a proper char array when casted.
Actually ignore the casting thing, looking at readText it takes a
template parameter.
So:
char[] a = readText!(char[])("filename");