module sdiff.mmblocks; import xdiff; import sdiff.init; import std.exception : enforce; import std.conv : to; private enum DEFAULT_BSIZE = 64 * 1024; final class MMBlocks : MM { public: this() { super(DEFAULT_BSIZE); } ~this() { if (_inner.head !is null) xdl_free_mmfile(&_inner); } package(sdiff) mmfile_t* ptr() @trusted { return &_inner; } const(ubyte)[] slice() const @trusted { enforce(isCompact(), "MMFile must be compact for asSliceConst"); auto h = _inner.head; return (h is null || h.size <= 0) ? [] : (cast(const(ubyte)*) h.ptr)[0 .. h.size.to!size_t]; } override string toString() const @trusted { return cast(string) slice(); } }