On Sat, Mar 14, 2020 at 10:37:37PM +0000, Adnan via Digitalmars-d-learn wrote:
> https://dlang.org/library/std/mmfile/mm_file.html doesn't seem to
> specify anything similar to lines() or byLine() or byLineCopy() etc.

That's because a memory-mapped file appears directly in your program's
memory address space as if it was an array of bytes (ubyte[]).  No
interpretation is imposed upon the contents.  If you want lines out of
it, try casting the memory to const(char)[] and using
std.algorithm.splitter to get a range of lines. For example:

        auto mmfile = new MmFile("myfile.txt");
        auto data = cast(const(char)[]) mmfile[];
        auto lines = data.splitter("\n");
        foreach (line; lines) {
                ...
        }


T

-- 
"You are a very disagreeable person." "NO."

Reply via email to