file-iodphobos

Byte InputRange from file


How to construct easily a raw byte-by-byte InputRange/ForwardRange/RandomAccessRange from a file?


Solution

  • file.byChunk(4096).joiner
    

    This reads a file in 4096-byte chunks and lazily joins the chunks together into a single ubyte input range.

    joiner is from std.algorithm, so you'll have to import it first.