Переписан для обычного diff

This commit is contained in:
Alexander Zhirov 2025-09-01 02:02:13 +03:00
parent ef491965f6
commit e7d16e6969
Signed by: alexander
GPG key ID: C8D8BE544A27C511
7 changed files with 212 additions and 15 deletions

View file

@ -0,0 +1,41 @@
module libxdiff.mmblocks;
import xdiff;
import libxdiff.init;
import std.exception : enforce;
import core.stdc.errno : errno;
import core.stdc.string : strerror;
import std.string : fromStringz;
import std.conv : to;
private enum DEFAULT_BSIZE = 8 * 1024;
final class MMBlocks : MM
{
public:
this()
{
_inner = initMmfile(DEFAULT_BSIZE);
}
package(libxdiff) mmfile_t* ptr() @trusted
{
return &_inner;
}
const(ubyte)[] asSlice() @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
{
enforce(isCompact(), "MMFile must be compact for asSliceConst");
auto h = _inner.head;
return h is null || h.size <= 0 ? [] : fromStringz(cast(const char*) h.ptr).idup;
}
}