diff options
author | srs5694 <srs5694@users.sourceforge.net> | 2010-02-19 17:19:55 -0500 |
---|---|---|
committer | srs5694 <srs5694@users.sourceforge.net> | 2010-02-19 17:19:55 -0500 |
commit | 08bb0da07953af605b4918e268272de15ac151aa (patch) | |
tree | 401ff14b62ddfda4c4c64b3dfcee817ad8133971 /gptpart.cc | |
parent | fad064250bf6c49eb4966bf0f617591a0821808e (diff) | |
download | sgdisk-08bb0da07953af605b4918e268272de15ac151aa.tar.gz |
Version 0.6.4
Diffstat (limited to 'gptpart.cc')
-rw-r--r-- | gptpart.cc | 39 |
1 files changed, 6 insertions, 33 deletions
@@ -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() |