Can not find related document in http://cakebuild.net/dsl/file-operations/
The cmake compares file date automatically, I'm wondering if there is similar facility in cakebuild?
There's no automatic file date comparing in Cake. It's just .NET so you can compare using System.IO
just as in regular .NET.
var fileA = new System.IO.FileInfo("./filea.txt");
var fileB = new System.IO.FileInfo("./fileb.txt");
if (fileA.LastWriteTime > fileB.LastWriteTime)
{
}
or
var modifiedA = System.IO.File.GetLastWriteTime("./filea.txt");
var modifiedB = System.IO.File.GetLastWriteTime("./fileb.txt");
if (modifiedA > modifiedB)
{
}
If you want to check if two files are identical or not then there's built-in functionality to get the hash of a given file with the CalculateFileHash alias.
var fileHashA = CalculateFileHash("filea.txt").ToHex();
var fileHashB = CalculateFileHash("fileb.txt").ToHex();
if (fileHashA != fileHashB)
{
//DIFF
}