| |
---|
| | |
---|
| | // guess whether 2 files are identical, ignores filename and content |
---|
| | private bool sameFile(Path a, Path b) |
---|
| | { |
---|
| | static assert(__traits(allMembers, FileInfo)[0] == "name"); |
---|
| | return getFileInfo(a).tupleof[1 .. $] == getFileInfo(b).tupleof[1 .. $]; |
---|
| | version (Posix) { |
---|
| | auto st_a = std.file.DirEntry(a.toNativeString).statBuf; |
---|
| | auto st_b = std.file.DirEntry(b.toNativeString).statBuf; |
---|
| | return st_a == st_b; |
---|
| | } else { |
---|
| | static assert(__traits(allMembers, FileInfo)[0] == "name"); |
---|
| | return getFileInfo(a).tupleof[1 .. $] == getFileInfo(b).tupleof[1 .. $]; |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | /** |
---|
| | Creates a hardlink. |
---|
| |
---|
| | { |
---|
| | if (existsFile(to)) { |
---|
| | enforce(overwrite, "Destination file already exists."); |
---|
| | if (auto fe = collectException!FileException(removeFile(to))) { |
---|
| | version (Windows) if (sameFile(from, to)) return; |
---|
| | if (sameFile(from, to)) return; |
---|
| | throw fe; |
---|
| | } |
---|
| | } |
---|
| | |
---|
| |
---|
| | |