srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 1 | // |
| 2 | // C++ Implementation: gptpart |
| 3 | // |
| 4 | // Description: Class to implement a SINGLE GPT partition |
| 5 | // |
| 6 | // |
Roderick W. Smith | e3ee733 | 2013-09-24 12:56:11 -0400 | [diff] [blame] | 7 | // Author: Rod Smith <rodsmith@rodsbooks.com>, (C) 2009-2013 |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 8 | // |
| 9 | // Copyright: See COPYING file that comes with this distribution |
| 10 | // |
| 11 | // |
srs5694 | 978041c | 2009-09-21 20:51:47 -0400 | [diff] [blame] | 12 | // This program is copyright (c) 2009 by Roderick W. Smith. It is distributed |
| 13 | // under the terms of the GNU GPL version 2, as detailed in the COPYING file. |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 14 | |
| 15 | #define __STDC_LIMIT_MACROS |
| 16 | #define __STDC_CONSTANT_MACROS |
| 17 | |
srs5694 | 00b6d7a | 2011-06-26 22:40:06 -0400 | [diff] [blame] | 18 | #ifdef USE_UTF16 |
srs5694 | 699941e | 2011-03-21 21:33:57 -0400 | [diff] [blame] | 19 | #include <unicode/ustdio.h> |
| 20 | #else |
| 21 | #define UnicodeString string |
| 22 | #endif |
| 23 | |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 24 | #include <string.h> |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 25 | #include <stdio.h> |
| 26 | #include <iostream> |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 27 | #include "gptpart.h" |
| 28 | #include "attributes.h" |
| 29 | |
| 30 | using namespace std; |
| 31 | |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 32 | GPTPart::GPTPart(void) { |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 33 | partitionType.Zero(); |
| 34 | uniqueGUID.Zero(); |
| 35 | firstLBA = 0; |
| 36 | lastLBA = 0; |
| 37 | attributes = 0; |
srs5694 | 64cbd17 | 2011-03-01 22:03:54 -0500 | [diff] [blame] | 38 | memset(name, 0, NAME_SIZE); |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 39 | } // Default constructor |
| 40 | |
| 41 | GPTPart::~GPTPart(void) { |
| 42 | } // destructor |
| 43 | |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 44 | // Return the gdisk-specific two-byte hex code for the partition |
srs5694 | bf8950c | 2011-03-12 01:23:12 -0500 | [diff] [blame] | 45 | uint16_t GPTPart::GetHexType(void) const { |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 46 | return partitionType.GetHexType(); |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 47 | } // GPTPart::GetHexType() |
| 48 | |
| 49 | // Return a plain-text description of the partition type (e.g., "Linux/Windows |
| 50 | // data" or "Linux swap"). |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 51 | string GPTPart::GetTypeName(void) { |
| 52 | return partitionType.TypeName(); |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 53 | } // GPTPart::GetNameType() |
| 54 | |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 55 | // Return a Unicode description of the partition type (e.g., "Linux/Windows |
| 56 | // data" or "Linux swap"). |
| 57 | UnicodeString GPTPart::GetUTypeName(void) { |
| 58 | return partitionType.UTypeName(); |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 59 | } // GPTPart::GetNameType() |
| 60 | |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 61 | // Compute and return the partition's length (or 0 if the end is incorrectly |
| 62 | // set before the beginning). |
srs5694 | bf8950c | 2011-03-12 01:23:12 -0500 | [diff] [blame] | 63 | uint64_t GPTPart::GetLengthLBA(void) const { |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 64 | uint64_t length = 0; |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 65 | |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 66 | if (firstLBA <= lastLBA) |
| 67 | length = lastLBA - firstLBA + UINT64_C(1); |
| 68 | return length; |
| 69 | } // GPTPart::GetLengthLBA() |
| 70 | |
srs5694 | 00b6d7a | 2011-06-26 22:40:06 -0400 | [diff] [blame] | 71 | #ifdef USE_UTF16 |
srs5694 | 699941e | 2011-03-21 21:33:57 -0400 | [diff] [blame] | 72 | // Return partition's name field, converted to a Unicode string |
| 73 | UnicodeString GPTPart::GetDescription(void) { |
| 74 | return (UChar*) name; |
| 75 | } // GPTPart::GetDescription() |
| 76 | #else |
| 77 | // Return partition's name field, converted to a C++ ASCII string |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 78 | string GPTPart::GetDescription(void) { |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 79 | string theName; |
srs5694 | 00b6d7a | 2011-06-26 22:40:06 -0400 | [diff] [blame] | 80 | int i = 0; |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 81 | |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 82 | theName = ""; |
srs5694 | 00b6d7a | 2011-06-26 22:40:06 -0400 | [diff] [blame] | 83 | while ((i < NAME_SIZE) && (name[i] != '\0')) { |
| 84 | theName += name[i]; |
| 85 | i+=2; |
| 86 | } // while |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 87 | return theName; |
srs5694 | 699941e | 2011-03-21 21:33:57 -0400 | [diff] [blame] | 88 | } // GPTPart::GetDescription() (Windows version) |
| 89 | #endif |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 90 | |
srs5694 | 08bb0da | 2010-02-19 17:19:55 -0500 | [diff] [blame] | 91 | // Return 1 if the partition is in use |
| 92 | int GPTPart::IsUsed(void) { |
srs5694 | e69e680 | 2012-01-20 22:37:12 -0500 | [diff] [blame] | 93 | return (partitionType != GUIDData("0x00")); |
srs5694 | 08bb0da | 2010-02-19 17:19:55 -0500 | [diff] [blame] | 94 | } // GPTPart::IsUsed() |
| 95 | |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 96 | // Set the type code to the specified one. Also changes the partition |
| 97 | // name *IF* the current name is the generic one for the current partition |
| 98 | // type. |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 99 | void GPTPart::SetType(PartType t) { |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 100 | if (GetDescription() == partitionType.UTypeName()) { |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 101 | SetName(t.TypeName()); |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 102 | } // if |
| 103 | partitionType = t; |
| 104 | } // GPTPart::SetType() |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 105 | |
srs5694 | 00b6d7a | 2011-06-26 22:40:06 -0400 | [diff] [blame] | 106 | #ifdef USE_UTF16 |
srs5694 | 699941e | 2011-03-21 21:33:57 -0400 | [diff] [blame] | 107 | // Set the name for a partition to theName, using a C++-style string as |
| 108 | // input. |
| 109 | void GPTPart::SetName(const string & theName) { |
| 110 | SetName((UnicodeString) theName.c_str()); |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 111 | } // GPTPart::SetName() |
| 112 | |
srs5694 | 699941e | 2011-03-21 21:33:57 -0400 | [diff] [blame] | 113 | // Set the name for a partition to theName, using a Unicode string as |
| 114 | // input. |
| 115 | void GPTPart::SetName(const UnicodeString & theName) { |
| 116 | if (theName.isBogus()) { |
| 117 | cerr << "Bogus UTF-16 name found in GPTPart::SetName()! Name not changed!\n"; |
| 118 | } else { |
| 119 | memset(name, 0, NAME_SIZE); |
| 120 | theName.extractBetween(0, NAME_SIZE / 2 - 1, (UChar*) name); |
| 121 | } // if/else |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 122 | } // GPTPart::SetName() |
srs5694 | 00b6d7a | 2011-06-26 22:40:06 -0400 | [diff] [blame] | 123 | |
srs5694 | 699941e | 2011-03-21 21:33:57 -0400 | [diff] [blame] | 124 | #else |
srs5694 | 00b6d7a | 2011-06-26 22:40:06 -0400 | [diff] [blame] | 125 | |
srs5694 | 699941e | 2011-03-21 21:33:57 -0400 | [diff] [blame] | 126 | // Set the name for a partition to theName. Note that theName is a |
| 127 | // standard C++-style ASCII string, although the GUID partition definition |
| 128 | // requires a UTF-16LE string. This function creates a simple-minded copy |
| 129 | // for this. |
| 130 | void GPTPart::SetName(const string & theName) { |
| 131 | int i, length; |
| 132 | |
| 133 | if (theName.length() < (NAME_SIZE / 2)) |
| 134 | length = theName.length(); |
| 135 | else |
| 136 | length = NAME_SIZE / 2; |
| 137 | memset(name, 0, NAME_SIZE); |
| 138 | for (i = 0; i < length; i++) |
| 139 | name[i * 2] = theName[i]; |
srs5694 | d8eed46 | 2012-12-15 01:55:21 -0500 | [diff] [blame] | 140 | } // GPTPart::SetName(), ASCII version |
srs5694 | 699941e | 2011-03-21 21:33:57 -0400 | [diff] [blame] | 141 | #endif |
srs5694 | a0eb11a | 2009-08-29 15:00:08 -0400 | [diff] [blame] | 142 | |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 143 | // Set the name for the partition based on the current GUID partition type |
| 144 | // code's associated name |
| 145 | void GPTPart::SetDefaultDescription(void) { |
| 146 | SetName(partitionType.TypeName()); |
| 147 | } // GPTPart::SetDefaultDescription() |
| 148 | |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 149 | GPTPart & GPTPart::operator=(const GPTPart & orig) { |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 150 | partitionType = orig.partitionType; |
| 151 | uniqueGUID = orig.uniqueGUID; |
| 152 | firstLBA = orig.firstLBA; |
| 153 | lastLBA = orig.lastLBA; |
| 154 | attributes = orig.attributes; |
srs5694 | 64cbd17 | 2011-03-01 22:03:54 -0500 | [diff] [blame] | 155 | memcpy(name, orig.name, NAME_SIZE); |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 156 | return *this; |
| 157 | } // assignment operator |
| 158 | |
srs5694 | 9a46b04 | 2011-03-15 00:34:10 -0400 | [diff] [blame] | 159 | // Compare the values, and return a bool result. |
| 160 | // Because this is intended for sorting and a firstLBA value of 0 denotes |
| 161 | // a partition that's not in use and so that should be sorted upwards, |
| 162 | // we return the opposite of the usual arithmetic result when either |
| 163 | // firstLBA value is 0. |
| 164 | bool GPTPart::operator<(const GPTPart &other) const { |
srs5694 | 9a46b04 | 2011-03-15 00:34:10 -0400 | [diff] [blame] | 165 | if (firstLBA && other.firstLBA) |
| 166 | return (firstLBA < other.firstLBA); |
| 167 | else |
| 168 | return (other.firstLBA < firstLBA); |
| 169 | } // GPTPart::operator<() |
| 170 | |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 171 | // Display summary information; does nothing if the partition is empty. |
| 172 | void GPTPart::ShowSummary(int partNum, uint32_t blockSize) { |
srs5694 | 01f7f08 | 2011-03-15 23:53:31 -0400 | [diff] [blame] | 173 | string sizeInIeee; |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 174 | UnicodeString description; |
srs5694 | 64cbd17 | 2011-03-01 22:03:54 -0500 | [diff] [blame] | 175 | size_t i; |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 176 | |
| 177 | if (firstLBA != 0) { |
srs5694 | 01f7f08 | 2011-03-15 23:53:31 -0400 | [diff] [blame] | 178 | sizeInIeee = BytesToIeee(lastLBA - firstLBA + 1, blockSize); |
srs5694 | 08bb0da | 2010-02-19 17:19:55 -0500 | [diff] [blame] | 179 | cout.fill(' '); |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 180 | cout.width(4); |
| 181 | cout << partNum + 1 << " "; |
| 182 | cout.width(14); |
| 183 | cout << firstLBA << " "; |
| 184 | cout.width(14); |
| 185 | cout << lastLBA << " "; |
srs5694 | 01f7f08 | 2011-03-15 23:53:31 -0400 | [diff] [blame] | 186 | cout << BytesToIeee(lastLBA - firstLBA + 1, blockSize) << " "; |
| 187 | if (sizeInIeee.length() < 10) |
| 188 | for (i = 0; i < 10 - sizeInIeee.length(); i++) |
| 189 | cout << " "; |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 190 | cout.fill('0'); |
| 191 | cout.width(4); |
| 192 | cout.setf(ios::uppercase); |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 193 | cout << hex << partitionType.GetHexType() << " " << dec; |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 194 | cout.fill(' '); |
srs5694 | 00b6d7a | 2011-06-26 22:40:06 -0400 | [diff] [blame] | 195 | #ifdef USE_UTF16 |
srs5694 | 699941e | 2011-03-21 21:33:57 -0400 | [diff] [blame] | 196 | GetDescription().extractBetween(0, 23, description); |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 197 | cout << description << "\n"; |
srs5694 | 699941e | 2011-03-21 21:33:57 -0400 | [diff] [blame] | 198 | #else |
| 199 | cout << GetDescription().substr(0, 23) << "\n"; |
| 200 | #endif |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 201 | cout.fill(' '); |
| 202 | } // if |
| 203 | } // GPTPart::ShowSummary() |
| 204 | |
| 205 | // Show detailed partition information. Does nothing if the partition is |
| 206 | // empty (as determined by firstLBA being 0). |
| 207 | void GPTPart::ShowDetails(uint32_t blockSize) { |
| 208 | uint64_t size; |
| 209 | |
| 210 | if (firstLBA != 0) { |
srs5694 | 5a08175 | 2010-09-24 20:39:41 -0400 | [diff] [blame] | 211 | cout << "Partition GUID code: " << partitionType; |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 212 | cout << " (" << partitionType.TypeName() << ")\n"; |
srs5694 | 5a08175 | 2010-09-24 20:39:41 -0400 | [diff] [blame] | 213 | cout << "Partition unique GUID: " << uniqueGUID << "\n"; |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 214 | |
| 215 | cout << "First sector: " << firstLBA << " (at " |
Roderick W. Smith | af39cb4 | 2013-08-06 15:23:46 -0400 | [diff] [blame] | 216 | << BytesToIeee(firstLBA, blockSize) << ")\n"; |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 217 | cout << "Last sector: " << lastLBA << " (at " |
Roderick W. Smith | af39cb4 | 2013-08-06 15:23:46 -0400 | [diff] [blame] | 218 | << BytesToIeee(lastLBA, blockSize) << ")\n"; |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 219 | size = (lastLBA - firstLBA + 1); |
| 220 | cout << "Partition size: " << size << " sectors (" |
Roderick W. Smith | af39cb4 | 2013-08-06 15:23:46 -0400 | [diff] [blame] | 221 | << BytesToIeee(size, blockSize) << ")\n"; |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 222 | cout << "Attribute flags: "; |
| 223 | cout.fill('0'); |
| 224 | cout.width(16); |
| 225 | cout << hex; |
| 226 | cout << attributes << "\n"; |
| 227 | cout << dec; |
srs5694 | 699941e | 2011-03-21 21:33:57 -0400 | [diff] [blame] | 228 | cout << "Partition name: '" << GetDescription() << "'\n"; |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 229 | cout.fill(' '); |
| 230 | } // if |
| 231 | } // GPTPart::ShowDetails() |
| 232 | |
| 233 | // Blank (delete) a single partition |
| 234 | void GPTPart::BlankPartition(void) { |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 235 | uniqueGUID.Zero(); |
| 236 | partitionType.Zero(); |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 237 | firstLBA = 0; |
| 238 | lastLBA = 0; |
| 239 | attributes = 0; |
srs5694 | 64cbd17 | 2011-03-01 22:03:54 -0500 | [diff] [blame] | 240 | memset(name, 0, NAME_SIZE); |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 241 | } // GPTPart::BlankPartition |
| 242 | |
| 243 | // Returns 1 if the two partitions overlap, 0 if they don't |
| 244 | int GPTPart::DoTheyOverlap(const GPTPart & other) { |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 245 | // Don't bother checking unless these are defined (both start and end points |
| 246 | // are 0 for undefined partitions, so just check the start points) |
srs5694 | 64cbd17 | 2011-03-01 22:03:54 -0500 | [diff] [blame] | 247 | return firstLBA && other.firstLBA && |
| 248 | (firstLBA <= other.lastLBA) != (lastLBA < other.firstLBA); |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 249 | } // GPTPart::DoTheyOverlap() |
| 250 | |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 251 | // Reverse the bytes of integral data types and of the UTF-16LE name; |
| 252 | // used on big-endian systems. |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 253 | void GPTPart::ReversePartBytes(void) { |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 254 | int i; |
| 255 | |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 256 | ReverseBytes(&firstLBA, 8); |
| 257 | ReverseBytes(&lastLBA, 8); |
| 258 | ReverseBytes(&attributes, 8); |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 259 | for (i = 0; i < NAME_SIZE; i += 2) |
| 260 | ReverseBytes(name + i, 2); |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 261 | } // GPTPart::ReverseBytes() |
| 262 | |
| 263 | /**************************************** |
| 264 | * Functions requiring user interaction * |
| 265 | ****************************************/ |
| 266 | |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 267 | // Change the type code on the partition. Also changes the name if the original |
| 268 | // name is the generic one for the partition type. |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 269 | void GPTPart::ChangeType(void) { |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 270 | string line; |
srs5694 | 64cbd17 | 2011-03-01 22:03:54 -0500 | [diff] [blame] | 271 | int changeName; |
srs5694 | 82f3f0b | 2010-09-22 10:50:24 -0400 | [diff] [blame] | 272 | PartType tempType = (GUIDData) "00000000-0000-0000-0000-000000000000"; |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 273 | |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 274 | changeName = (GetDescription() == GetUTypeName()); |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 275 | |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 276 | cout << "Current type is '" << GetTypeName() << "'\n"; |
srs5694 | 82f3f0b | 2010-09-22 10:50:24 -0400 | [diff] [blame] | 277 | do { |
srs5694 | 0741fa2 | 2013-01-09 12:55:40 -0500 | [diff] [blame] | 278 | cout << "Hex code or GUID (L to show codes, Enter = " << hex << DEFAULT_GPT_TYPE << dec << "): "; |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 279 | line = ReadString(); |
srs5694 | 82f3f0b | 2010-09-22 10:50:24 -0400 | [diff] [blame] | 280 | if ((line[0] == 'L') || (line[0] == 'l')) { |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 281 | partitionType.ShowAllTypes(); |
srs5694 | 82f3f0b | 2010-09-22 10:50:24 -0400 | [diff] [blame] | 282 | } else { |
srs5694 | 5a60853 | 2011-03-17 13:53:01 -0400 | [diff] [blame] | 283 | if (line.length() == 0) |
srs5694 | 0741fa2 | 2013-01-09 12:55:40 -0500 | [diff] [blame] | 284 | tempType = DEFAULT_GPT_TYPE; |
srs5694 | 82f3f0b | 2010-09-22 10:50:24 -0400 | [diff] [blame] | 285 | else |
| 286 | tempType = line; |
| 287 | } // if/else |
| 288 | } while (tempType == (GUIDData) "00000000-0000-0000-0000-000000000000"); |
| 289 | partitionType = tempType; |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 290 | cout << "Changed type of partition to '" << partitionType.TypeName() << "'\n"; |
| 291 | if (changeName) { |
| 292 | SetDefaultDescription(); |
| 293 | } // if |
srs5694 | 0a69731 | 2010-01-28 21:10:52 -0500 | [diff] [blame] | 294 | } // GPTPart::ChangeType() |