Merge pull request #511 from MartinNowak/fix511
copyFiles should not overwrite identical files on windows
commit 16ea26bd51ba4fb804c144df2433109255cd5a6e
2 parents 83b2926 + bfc41df
@Martin Nowak Martin Nowak authored on 16 Feb 2015
Showing 1 changed file
View
15
source/dub/internal/vibecompat/core/file.d
}
 
version (Windows) extern(Windows) int CreateHardLinkW(in wchar* to, in wchar* from, void* attr=null);
 
// 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 .. $];
}
 
/**
Creates a hardlink.
*/
void hardLinkFile(Path from, Path to, bool overwrite = false)
{
if (existsFile(to)) {
enforce(overwrite, "Destination file already exists.");
removeFile(to);
if (auto fe = collectException!FileException(removeFile(to))) {
version (Windows) if (sameFile(from, to)) return;
throw fe;
}
}
 
version (Windows)
{