diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-12-15 19:25:50 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-12-15 19:25:50 -0800 |
commit | 8c0bcde31654fc4a0efff526b37b8fc386175abb (patch) | |
tree | 6201d5004323daf083bf1196bd4ffa103fb2891d /src/DotNetOpenAuth.BuildTasks/CompareFiles.cs | |
parent | a59adef3b04544b519ce9d1d8110ba456fee159d (diff) | |
download | DotNetOpenAuth-8c0bcde31654fc4a0efff526b37b8fc386175abb.zip DotNetOpenAuth-8c0bcde31654fc4a0efff526b37b8fc386175abb.tar.gz DotNetOpenAuth-8c0bcde31654fc4a0efff526b37b8fc386175abb.tar.bz2 |
Fixed incremental build when the project template transformation changes.
Diffstat (limited to 'src/DotNetOpenAuth.BuildTasks/CompareFiles.cs')
-rw-r--r-- | src/DotNetOpenAuth.BuildTasks/CompareFiles.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.BuildTasks/CompareFiles.cs b/src/DotNetOpenAuth.BuildTasks/CompareFiles.cs index 691df20..51fcee4 100644 --- a/src/DotNetOpenAuth.BuildTasks/CompareFiles.cs +++ b/src/DotNetOpenAuth.BuildTasks/CompareFiles.cs @@ -81,5 +81,32 @@ namespace DotNetOpenAuth.BuildTasks { return true; } + + /// <summary> + /// Tests whether a file is up to date with respect to another, + /// based on existence, last write time and file size. + /// </summary> + /// <param name="sourcePath">The source path.</param> + /// <param name="destPath">The dest path.</param> + /// <returns><c>true</c> if the files are the same; <c>false</c> if the files are different</returns> + internal static bool FastFileEqualityCheck(string sourcePath, string destPath) { + FileInfo sourceInfo = new FileInfo(sourcePath); + FileInfo destInfo = new FileInfo(destPath); + + if (sourceInfo.Exists ^ destInfo.Exists) { + // Either the source file or the destination file is missing. + return false; + } + + if (!sourceInfo.Exists) { + // Neither file exists. + return true; + } + + // We'll say the files are the same if their modification date and length are the same. + return + sourceInfo.LastWriteTimeUtc == destInfo.LastWriteTimeUtc && + sourceInfo.Length == destInfo.Length; + } } } |