summaryrefslogtreecommitdiff
path: root/mbrpart.cc
diff options
context:
space:
mode:
authorsrs5694 <srs5694@users.sourceforge.net>2011-03-16 02:42:33 -0400
committersrs5694 <srs5694@users.sourceforge.net>2011-03-16 02:42:33 -0400
commitc2f6e0cb812dd08fdb8f8cabda4f08a070c6f9fe (patch)
tree24934b43df063f9889923f8c6b373f84aca66932 /mbrpart.cc
parent01f7f08624f0c942001977415214a578621f6495 (diff)
downloadsgdisk-c2f6e0cb812dd08fdb8f8cabda4f08a070c6f9fe.tar.gz
A few miscellaneous changes
Diffstat (limited to 'mbrpart.cc')
-rw-r--r--mbrpart.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/mbrpart.cc b/mbrpart.cc
index 0214f48..f0e4f90 100644
--- a/mbrpart.cc
+++ b/mbrpart.cc
@@ -102,6 +102,18 @@ MBRPart& MBRPart::operator=(const struct MBRRecord& orig) {
return *this;
} // MBRPart::operator=(const struct MBRRecord& orig)
+// Compare the values, and return a bool result.
+// Because this is intended for sorting and a lengthLBA value of 0 denotes
+// a partition that's not in use and so that should be sorted upwards,
+// we return the opposite of the usual arithmetic result when either
+// lengthLBA value is 0.
+bool MBRPart::operator<(const MBRPart &other) const {
+ if (lengthLBA && other.lengthLBA)
+ return (firstLBA < other.firstLBA);
+ else
+ return (other.firstLBA < firstLBA);
+} // operator<()
+
/**************************************************
* *
* Set information on partitions or disks without *