file rawRead and rawWrite in chunks example
Jay Norwood via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Aug 9 07:37:46 PDT 2015
On Sunday, 9 August 2015 at 11:06:34 UTC, Nordlöw wrote:
> On Sunday, 9 August 2015 at 10:40:06 UTC, Nordlöw wrote:
>> Couldn't the chunk logic be deduced aswell?
>
> Yes :)
>
> See update at:
>
> https://github.com/nordlow/justd/blob/a633b52876388921ec49c189f374746f7b4d8c93/tests/t_rawio.d
>
>> What would a suitable value for `preferred_disk_write_size` be?
>
> Is there a suitable constant somewhere in Phobos?
So, to be clear, I think you must be saying that you want to
specify the disk chunk size separate from the array size. Is
that correct?
I stepped through the original code (with the foreach loops) and
I see single calls to fwrite and fread for each array.
The rawWrite is executing a single fwrite per array
f.rawWrite(elem.array())
auto result =
.fwrite(buffer.ptr, T.sizeof, buffer.length,
_p.handle);
The rawRead is executing a sing fread per array
immutable result =
fread(buffer.ptr, T.sizeof, buffer.length, _p.handle);
More information about the Digitalmars-d-learn
mailing list