diff options
Diffstat (limited to 'cpp/include/IcePatch2/Util.h')
-rw-r--r-- | cpp/include/IcePatch2/Util.h | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/cpp/include/IcePatch2/Util.h b/cpp/include/IcePatch2/Util.h index 6a2c0c5d4fb..3d0c500155a 100644 --- a/cpp/include/IcePatch2/Util.h +++ b/cpp/include/IcePatch2/Util.h @@ -44,12 +44,25 @@ struct FileInfoEqual: public std::binary_function<const FileInfo&, const FileInf bool operator()(const FileInfo& lhs, const FileInfo& rhs) { - return lhs.path == rhs.path && lhs.checksum < rhs.checksum; + if(lhs.path != rhs.path) + { + return false; + } // - // We don't take the size int account, as it might not be set - // if no compressed file is available. + // For the size portion of the comparison, we only distinquish + // between file (size >= 0) and directory (size == -1). We do + // not take the actual size into account, as it might be set + // to 0 if no compressed file is available. // + Ice::Int lsz = lhs.size > 0 ? 0 : lhs.size; + Ice::Int rsz = rhs.size > 0 ? 0 : rhs.size; + if(lsz != rsz) + { + return false; + } + + return lhs.checksum == rhs.checksum; } }; @@ -67,12 +80,24 @@ struct FileInfoLess: public std::binary_function<const FileInfo&, const FileInfo return false; } - return lhs.checksum < rhs.checksum; - // - // We don't take the size int account, as it might not be set - // if no compressed file is available. + // For the size portion of the comparison, we only distinquish + // between file (size >= 0) and directory (size == -1). We do + // not take the actual size into account, as it might be set + // to 0 if no compressed file is available. // + Ice::Int lsz = lhs.size > 0 ? 0 : lhs.size; + Ice::Int rsz = rhs.size > 0 ? 0 : rhs.size; + if(lsz < rsz) + { + return true; + } + else if(rsz < lsz) + { + return false; + } + + return lhs.checksum < rhs.checksum; } }; |