Phobos function to check if files are identical?
Andrea Fontana via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 14 01:12:16 PDT 2017
On Monday, 13 March 2017 at 17:47:09 UTC, H. S. Teoh wrote:
> bool isEqual(string filename1, string filename2) {
> import std.algorithm.comparison : equal;
> import std.range : zip;
> import std.stdio : File, chunks;
>
> auto f1 = File(filename1);
> auto f2 = File(filename2);
>
> size_t blockSize = 4096; // or something similar
>
> return f1.chunks(blockSize).equal(f2.chunks(blockSize));
> }
First I would check if the files have different size or if they
are the same file (same path, symlink, etc).
More information about the Digitalmars-d-learn
mailing list