summaryrefslogtreecommitdiff
path: root/gptpart.cc
diff options
context:
space:
mode:
authorsrs5694 <srs5694@users.sourceforge.net>2010-02-19 17:19:55 -0500
committersrs5694 <srs5694@users.sourceforge.net>2010-02-19 17:19:55 -0500
commit08bb0da07953af605b4918e268272de15ac151aa (patch)
tree401ff14b62ddfda4c4c64b3dfcee817ad8133971 /gptpart.cc
parentfad064250bf6c49eb4966bf0f617591a0821808e (diff)
downloadsgdisk-08bb0da07953af605b4918e268272de15ac151aa.tar.gz
Version 0.6.4
Diffstat (limited to 'gptpart.cc')
-rw-r--r--gptpart.cc39
1 files changed, 6 insertions, 33 deletions
diff --git a/gptpart.cc b/gptpart.cc
index 283eb3d..d82c0f6 100644
--- a/gptpart.cc
+++ b/gptpart.cc
@@ -66,6 +66,11 @@ string GPTPart::GetDescription(void) {
return theName;
} // GPTPart::GetDescription()
+// Return 1 if the partition is in use
+int GPTPart::IsUsed(void) {
+ return (firstLBA != UINT64_C(0));
+} // GPTPart::IsUsed()
+
// Set the type code to the specified one. Also changes the partition
// name *IF* the current name is the generic one for the current partition
// type.
@@ -139,6 +144,7 @@ void GPTPart::ShowSummary(int partNum, uint32_t blockSize) {
if (firstLBA != 0) {
sizeInSI = BytesToSI(blockSize * (lastLBA - firstLBA + 1));
+ cout.fill(' ');
cout.width(4);
cout << partNum + 1 << " ";
cout.width(14);
@@ -256,36 +262,3 @@ void GPTPart::ChangeType(void) {
SetDefaultDescription();
} // if
} // GPTPart::ChangeType()
-
-/***********************************
- * Non-class but related functions *
- ***********************************/
-
-// Recursive quick sort algorithm for GPT partitions. Note that if there
-// are any empties in the specified range, they'll be sorted to the
-// start, resulting in a sorted set of partitions that begins with
-// partition 2, 3, or higher.
-void QuickSortGPT(GPTPart* partitions, int start, int finish) {
- uint64_t starterValue; // starting location of median partition
- int left, right;
- GPTPart temp;
-
- left = start;
- right = finish;
- starterValue = partitions[(start + finish) / 2].GetFirstLBA();
- do {
- while (partitions[left].GetFirstLBA() < starterValue)
- left++;
- while (partitions[right].GetFirstLBA() > starterValue)
- right--;
- if (left <= right) {
- temp = partitions[left];
- partitions[left] = partitions[right];
- partitions[right] = temp;
- left++;
- right--;
- } // if
- } while (left <= right);
- if (start < right) QuickSortGPT(partitions, start, right);
- if (finish > left) QuickSortGPT(partitions, left, finish);
-} // QuickSortGPT()