On Thursday, 22 October 2015 at 18:20:07 UTC, pineapple wrote:
I'd like to use fread and fwrite in place of File.rawRead and File.rawWrite which force the creation of an array where I'd rather specify a buffer location and length.
D's arrays *are* just buffer locations and lengths with a few extra properties, methods and operators.
T* ptrToBuffer = /* ... */; size_t lengthOfBuffer = /* ... */; T[] buffer = ptrToBuffer[0 .. lengthOfBuffer]; File f = /* ... */; T[] filledPartOfBuffer = f.rawRead(buffer); Note that at no point in the above is a new buffer allocated.