Переписан для обычного diff
This commit is contained in:
parent
ef491965f6
commit
e7d16e6969
7 changed files with 212 additions and 15 deletions
41
source/libxdiff/mmblocks.d
Normal file
41
source/libxdiff/mmblocks.d
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue