blob: 7e899092a36931bd9f66ab6d1f9e1a9dfe0ddfc6 [file] [log] [blame]
srs5694a0eb11a2009-08-29 15:00:08 -04001//
2// C++ Implementation: gptpart
3//
4// Description: Class to implement a SINGLE GPT partition
5//
6//
Roderick W. Smithe3ee7332013-09-24 12:56:11 -04007// Author: Rod Smith <rodsmith@rodsbooks.com>, (C) 2009-2013
srs5694a0eb11a2009-08-29 15:00:08 -04008//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
srs5694978041c2009-09-21 20:51:47 -040012// 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.
srs5694a0eb11a2009-08-29 15:00:08 -040014
15#define __STDC_LIMIT_MACROS
Aurimas Liutikasfcad0602016-05-10 19:16:10 -070016#ifndef __STDC_CONSTANT_MACROS
srs5694a0eb11a2009-08-29 15:00:08 -040017#define __STDC_CONSTANT_MACROS
Aurimas Liutikasfcad0602016-05-10 19:16:10 -070018#endif
srs5694a0eb11a2009-08-29 15:00:08 -040019
srs569400b6d7a2011-06-26 22:40:06 -040020#ifdef USE_UTF16
srs5694699941e2011-03-21 21:33:57 -040021#include <unicode/ustdio.h>
22#else
23#define UnicodeString string
24#endif
25
srs5694a0eb11a2009-08-29 15:00:08 -040026#include <string.h>
srs5694fed16d02010-01-27 23:03:40 -050027#include <stdio.h>
28#include <iostream>
srs5694a0eb11a2009-08-29 15:00:08 -040029#include "gptpart.h"
30#include "attributes.h"
31
32using namespace std;
33
srs5694a0eb11a2009-08-29 15:00:08 -040034GPTPart::GPTPart(void) {
srs569455d92612010-03-07 22:16:07 -050035 partitionType.Zero();
36 uniqueGUID.Zero();
37 firstLBA = 0;
38 lastLBA = 0;
39 attributes = 0;
Roderick W. Smith84aaff62014-02-17 16:17:11 -050040 memset(name, 0, NAME_SIZE * sizeof(name[0]) );
srs5694a0eb11a2009-08-29 15:00:08 -040041} // Default constructor
42
43GPTPart::~GPTPart(void) {
44} // destructor
45
srs5694a0eb11a2009-08-29 15:00:08 -040046// Return the gdisk-specific two-byte hex code for the partition
srs5694bf8950c2011-03-12 01:23:12 -050047uint16_t GPTPart::GetHexType(void) const {
srs56946699b012010-02-04 00:55:30 -050048 return partitionType.GetHexType();
srs5694a0eb11a2009-08-29 15:00:08 -040049} // GPTPart::GetHexType()
50
51// Return a plain-text description of the partition type (e.g., "Linux/Windows
52// data" or "Linux swap").
srs56946699b012010-02-04 00:55:30 -050053string GPTPart::GetTypeName(void) {
54 return partitionType.TypeName();
srs5694a0eb11a2009-08-29 15:00:08 -040055} // GPTPart::GetNameType()
56
Roderick W. Smith84aaff62014-02-17 16:17:11 -050057#ifdef USE_UTF16
srs56945a608532011-03-17 13:53:01 -040058// Return a Unicode description of the partition type (e.g., "Linux/Windows
59// data" or "Linux swap").
60UnicodeString GPTPart::GetUTypeName(void) {
61 return partitionType.UTypeName();
srs56945a608532011-03-17 13:53:01 -040062} // GPTPart::GetNameType()
Roderick W. Smith84aaff62014-02-17 16:17:11 -050063#endif
srs56945a608532011-03-17 13:53:01 -040064
srs5694a0eb11a2009-08-29 15:00:08 -040065// Compute and return the partition's length (or 0 if the end is incorrectly
66// set before the beginning).
srs5694bf8950c2011-03-12 01:23:12 -050067uint64_t GPTPart::GetLengthLBA(void) const {
srs5694a0eb11a2009-08-29 15:00:08 -040068 uint64_t length = 0;
srs569455d92612010-03-07 22:16:07 -050069
srs5694a0eb11a2009-08-29 15:00:08 -040070 if (firstLBA <= lastLBA)
71 length = lastLBA - firstLBA + UINT64_C(1);
72 return length;
73} // GPTPart::GetLengthLBA()
74
srs569400b6d7a2011-06-26 22:40:06 -040075#ifdef USE_UTF16
srs5694699941e2011-03-21 21:33:57 -040076// Return partition's name field, converted to a Unicode string
77UnicodeString GPTPart::GetDescription(void) {
78 return (UChar*) name;
79} // GPTPart::GetDescription()
80#else
Roderick W. Smith84aaff62014-02-17 16:17:11 -050081// Return partition's name field, converted to a C++ UTF-8 string
srs56946699b012010-02-04 00:55:30 -050082string GPTPart::GetDescription(void) {
Roderick W. Smith84aaff62014-02-17 16:17:11 -050083 // convert name to utf32 then to utf8
84 string utf8 ;
85 size_t pos = 0 ;
86 while ( ( pos < NAME_SIZE ) && ( name[ pos ] != 0 ) ) {
87 uint16_t cp = name[ pos ++ ] ;
88 if ( ! IsLittleEndian() ) ReverseBytes( & cp , 2 ) ;
89 // first to utf32
90 uint32_t uni ;
91 if ( cp < 0xd800 || cp > 0xdfff ) {
92 uni = cp ;
93 } // if
94 else if ( cp < 0xdc00 ) {
95 // lead surrogate
96 uni = ( (uint32_t)( cp & 0x3ff ) ) << 10 ;
97 if ( pos >= NAME_SIZE ) {
98 // missing trail surrogate, name[] is invalid
99 break ;
100 } // if
101 cp = name[ pos ++ ] ;
102 if ( cp < 0xdc00 || cp > 0xdfff ) {
103 // invalid trail surrogate, name[] is invalid
104 break ;
105 } // if
106 // trail surrogate
107 uni |= cp & 0x3ff ;
108 uni += 0x10000 ;
109 } // if
110 else {
111 // unexpected trail surrogate, name[] is invalid
112 break ;
113 } // if
114 // then to utf8
115 if ( uni < 0x80 ) {
116 utf8 += (char) uni ;
117 } // if
118 else if ( uni < 0x800 ) {
119 utf8 += (char) ( 0xc0 | ( uni >> 6 ) ) ;
120 utf8 += (char) ( 0x80 | ( uni & 0x3f ) ) ;
121 } // if
122 else if ( uni < 0x10000 ) {
123 utf8 += (char) ( 0xe0 | ( uni >> 12 ) ) ;
124 utf8 += (char) ( 0x80 | ( ( uni >> 6 ) & 0x3f ) ) ;
125 utf8 += (char) ( 0x80 | ( uni & 0x3f ) ) ;
126 } // if
127 else {
128 utf8 += (char) ( 0xf0 | ( uni >> 18 ) ) ;
129 utf8 += (char) ( 0xe0 | ( ( uni >> 12 ) & 0x3f ) ) ;
130 utf8 += (char) ( 0x80 | ( ( uni >> 6 ) & 0x3f ) ) ;
131 utf8 += (char) ( 0x80 | ( uni & 0x3f ) ) ;
132 } // if
133 }
134 return utf8 ;
135} // GPTPart::GetDescription(), UTF-8 version
srs5694699941e2011-03-21 21:33:57 -0400136#endif
srs56940a697312010-01-28 21:10:52 -0500137
srs569408bb0da2010-02-19 17:19:55 -0500138// Return 1 if the partition is in use
139int GPTPart::IsUsed(void) {
srs5694e69e6802012-01-20 22:37:12 -0500140 return (partitionType != GUIDData("0x00"));
srs569408bb0da2010-02-19 17:19:55 -0500141} // GPTPart::IsUsed()
142
Roderick W. Smitha345a922014-02-22 12:12:32 -0500143// Returns MBR_SIZED_GOOD, MBR_SIZED_IFFY, or MBR_SIZED_BAD; see comments
144// in header file for details.
Roderick W. Smith9b338c52014-02-20 11:13:36 -0500145int GPTPart::IsSizedForMBR(void) {
Roderick W. Smitha345a922014-02-22 12:12:32 -0500146 int retval = MBR_SIZED_GOOD;
147
148 if ((firstLBA > UINT32_MAX) || ((lastLBA - firstLBA) > UINT32_MAX) || (firstLBA > lastLBA))
149 retval = MBR_SIZED_BAD;
150 else if (lastLBA > UINT32_MAX)
151 retval = MBR_SIZED_IFFY;
152
153 return (retval);
Roderick W. Smith9b338c52014-02-20 11:13:36 -0500154} // GPTPart::IsSizedForMBR()
155
srs56940a697312010-01-28 21:10:52 -0500156// Set the type code to the specified one. Also changes the partition
157// name *IF* the current name is the generic one for the current partition
158// type.
srs56946699b012010-02-04 00:55:30 -0500159void GPTPart::SetType(PartType t) {
Roderick W. Smith84aaff62014-02-17 16:17:11 -0500160#ifdef USE_UTF16
srs56945a608532011-03-17 13:53:01 -0400161 if (GetDescription() == partitionType.UTypeName()) {
Roderick W. Smith84aaff62014-02-17 16:17:11 -0500162#else
163 if (GetDescription() == partitionType.TypeName()) {
164#endif
srs56946699b012010-02-04 00:55:30 -0500165 SetName(t.TypeName());
srs56940a697312010-01-28 21:10:52 -0500166 } // if
167 partitionType = t;
168} // GPTPart::SetType()
srs5694a0eb11a2009-08-29 15:00:08 -0400169
srs569400b6d7a2011-06-26 22:40:06 -0400170#ifdef USE_UTF16
srs5694699941e2011-03-21 21:33:57 -0400171// Set the name for a partition to theName, using a C++-style string as
172// input.
173void GPTPart::SetName(const string & theName) {
174 SetName((UnicodeString) theName.c_str());
srs56945a608532011-03-17 13:53:01 -0400175} // GPTPart::SetName()
176
srs5694699941e2011-03-21 21:33:57 -0400177// Set the name for a partition to theName, using a Unicode string as
178// input.
179void GPTPart::SetName(const UnicodeString & theName) {
180 if (theName.isBogus()) {
181 cerr << "Bogus UTF-16 name found in GPTPart::SetName()! Name not changed!\n";
182 } else {
Roderick W. Smith84aaff62014-02-17 16:17:11 -0500183 memset(name, 0, NAME_SIZE * sizeof(name[0]) );
184 theName.extractBetween(0, NAME_SIZE, (UChar*) name);
srs5694699941e2011-03-21 21:33:57 -0400185 } // if/else
srs5694a0eb11a2009-08-29 15:00:08 -0400186} // GPTPart::SetName()
srs569400b6d7a2011-06-26 22:40:06 -0400187
srs5694699941e2011-03-21 21:33:57 -0400188#else
srs569400b6d7a2011-06-26 22:40:06 -0400189
srs5694699941e2011-03-21 21:33:57 -0400190// Set the name for a partition to theName. Note that theName is a
191// standard C++-style ASCII string, although the GUID partition definition
192// requires a UTF-16LE string. This function creates a simple-minded copy
193// for this.
194void GPTPart::SetName(const string & theName) {
Roderick W. Smith84aaff62014-02-17 16:17:11 -0500195 // convert utf8 to utf32 then to utf16le
196 size_t len = theName.length() ;
197 size_t pos = 0 ;
198 for ( size_t i = 0 ; pos < NAME_SIZE && i < len ; ) {
199 uint32_t uni ;
200 uint8_t cp = theName[ i ++ ] ;
201 int todo ;
202 if ( cp < 0x80 ) {
203 uni = cp ;
204 todo = 0 ;
205 } // if
206 else if ( cp < 0xc0 || cp > 0xf7 ) {
207 // invalid byte, theName is broken
208 break ;
209 } // if
210 else if ( cp < 0xe0 ) {
211 uni = cp & 0x1f ;
212 todo = 1 ;
213 } // if
214 else if ( cp < 0xf0 ) {
215 uni = cp & 0x0f ;
216 todo = 2 ;
217 } // if
218 else {
219 uni = cp & 0x7 ;
220 todo = 3 ;
221 } // if
222 while ( todo > 0 ) {
223 if ( i >= len ) {
224 // missing continuation byte, theName is broken
225 goto break_converter ;
226 } // if
227 cp = theName[ i ++ ] ;
228 if ( cp > 0xbf || cp < 0x80 ) {
229 // invalid continuation byte, theName is broken
230 goto break_converter ;
231 } // if
232 uni <<= 6 ;
233 uni |= cp & 0x3f ;
234 todo -- ;
235 } // while
236 // then to utf16le
237 if ( uni < 0x10000 ) {
238 name[ pos ] = (uint16_t) uni ;
239 if ( ! IsLittleEndian() ) ReverseBytes( name + pos , 2 ) ;
240 pos ++ ;
241 } // if
242 else {
243 if ( pos > NAME_SIZE - 2 ) {
244 // not enough room for two surrogates, truncate
245 break ;
246 } // if
247 uni -= 0x10000 ;
248 name[ pos ] = (uint16_t)( uni >> 10 ) | 0xd800 ;
249 if ( ! IsLittleEndian() ) ReverseBytes( name + pos , 2 ) ;
250 pos ++ ;
251 name[ pos ] = (uint16_t)( uni & 0x3ff ) | 0xdc00 ;
252 if ( ! IsLittleEndian() ) ReverseBytes( name + pos , 2 ) ;
253 pos ++ ;
254 }
255 } // for
256 break_converter : ;
257 // finally fill with zeroes
258 while ( pos < NAME_SIZE ) {
259 name[ pos ++ ] = 0 ;
260 } // while
261} // GPTPart::SetName(), UTF-8 version
srs5694699941e2011-03-21 21:33:57 -0400262#endif
srs5694a0eb11a2009-08-29 15:00:08 -0400263
srs56946699b012010-02-04 00:55:30 -0500264// Set the name for the partition based on the current GUID partition type
265// code's associated name
266void GPTPart::SetDefaultDescription(void) {
267 SetName(partitionType.TypeName());
268} // GPTPart::SetDefaultDescription()
269
srs56940a697312010-01-28 21:10:52 -0500270GPTPart & GPTPart::operator=(const GPTPart & orig) {
srs56940a697312010-01-28 21:10:52 -0500271 partitionType = orig.partitionType;
272 uniqueGUID = orig.uniqueGUID;
273 firstLBA = orig.firstLBA;
274 lastLBA = orig.lastLBA;
275 attributes = orig.attributes;
Roderick W. Smith84aaff62014-02-17 16:17:11 -0500276 memcpy(name, orig.name, NAME_SIZE * sizeof( name[ 0 ] ) );
srs56940a697312010-01-28 21:10:52 -0500277 return *this;
278} // assignment operator
279
srs56949a46b042011-03-15 00:34:10 -0400280// Compare the values, and return a bool result.
281// Because this is intended for sorting and a firstLBA value of 0 denotes
282// a partition that's not in use and so that should be sorted upwards,
283// we return the opposite of the usual arithmetic result when either
284// firstLBA value is 0.
285bool GPTPart::operator<(const GPTPart &other) const {
srs56949a46b042011-03-15 00:34:10 -0400286 if (firstLBA && other.firstLBA)
287 return (firstLBA < other.firstLBA);
288 else
289 return (other.firstLBA < firstLBA);
290} // GPTPart::operator<()
291
srs56940a697312010-01-28 21:10:52 -0500292// Display summary information; does nothing if the partition is empty.
293void GPTPart::ShowSummary(int partNum, uint32_t blockSize) {
srs569401f7f082011-03-15 23:53:31 -0400294 string sizeInIeee;
srs56945a608532011-03-17 13:53:01 -0400295 UnicodeString description;
srs569464cbd172011-03-01 22:03:54 -0500296 size_t i;
srs56940a697312010-01-28 21:10:52 -0500297
298 if (firstLBA != 0) {
srs569401f7f082011-03-15 23:53:31 -0400299 sizeInIeee = BytesToIeee(lastLBA - firstLBA + 1, blockSize);
srs569408bb0da2010-02-19 17:19:55 -0500300 cout.fill(' ');
srs56940a697312010-01-28 21:10:52 -0500301 cout.width(4);
302 cout << partNum + 1 << " ";
303 cout.width(14);
304 cout << firstLBA << " ";
305 cout.width(14);
306 cout << lastLBA << " ";
Roderick W. Smithf6948032014-03-29 00:27:33 -0400307 cout << sizeInIeee << " ";
srs569401f7f082011-03-15 23:53:31 -0400308 if (sizeInIeee.length() < 10)
309 for (i = 0; i < 10 - sizeInIeee.length(); i++)
310 cout << " ";
srs56940a697312010-01-28 21:10:52 -0500311 cout.fill('0');
312 cout.width(4);
313 cout.setf(ios::uppercase);
srs56946699b012010-02-04 00:55:30 -0500314 cout << hex << partitionType.GetHexType() << " " << dec;
srs56940a697312010-01-28 21:10:52 -0500315 cout.fill(' ');
srs569400b6d7a2011-06-26 22:40:06 -0400316#ifdef USE_UTF16
srs5694699941e2011-03-21 21:33:57 -0400317 GetDescription().extractBetween(0, 23, description);
srs56945a608532011-03-17 13:53:01 -0400318 cout << description << "\n";
srs5694699941e2011-03-21 21:33:57 -0400319#else
Roderick W. Smith84aaff62014-02-17 16:17:11 -0500320 string desc = GetDescription() ;
321 size_t n = 0 ;
322 size_t i = 0 ;
323 size_t len = desc.length() ;
324 while ( n < 22 && i < len ) {
325 i ++ ;
326 if ( i >= len ) {
327 // short description
328 break ;
329 } // if
330 // skip continuation bytes
331 while ( i < len && ( ( desc[ i ] & 0xC0 ) == 0x80 ) ) {
332 // utf8 continuation byte
333 i ++ ;
334 } // while
335 n ++ ;
336 } // while
337 if ( i < len ) {
338 n = 0 ;
339 i = 0 ;
340 // description is long we will truncate it
341 while ( n < 19 && i < len ) {
342 i ++ ;
343 if ( i >= len ) {
344 // should not happen
345 break ;
346 } // if
347 // skip continuation bytes
348 while ( i < len && ( ( desc[ i ] & 0xC0 ) == 0x80 ) ) {
349 // utf8 continuation byte
350 i ++ ;
351 } // while
352 n ++ ;
353 } // while
354 } // for
355 cout << GetDescription().substr( 0 , i ) ;
356 if ( i < len ) cout << "..." ;
357 cout << "\n";
srs5694699941e2011-03-21 21:33:57 -0400358#endif
srs56940a697312010-01-28 21:10:52 -0500359 cout.fill(' ');
360 } // if
361} // GPTPart::ShowSummary()
362
363// Show detailed partition information. Does nothing if the partition is
364// empty (as determined by firstLBA being 0).
Jeff Sharkeyd761ff52015-02-28 19:18:39 -0800365void GPTPart::ShowDetails(uint32_t blockSize) {
srs56940a697312010-01-28 21:10:52 -0500366 uint64_t size;
367
368 if (firstLBA != 0) {
srs56945a081752010-09-24 20:39:41 -0400369 cout << "Partition GUID code: " << partitionType;
srs56946699b012010-02-04 00:55:30 -0500370 cout << " (" << partitionType.TypeName() << ")\n";
srs56945a081752010-09-24 20:39:41 -0400371 cout << "Partition unique GUID: " << uniqueGUID << "\n";
srs56940a697312010-01-28 21:10:52 -0500372
373 cout << "First sector: " << firstLBA << " (at "
Roderick W. Smithaf39cb42013-08-06 15:23:46 -0400374 << BytesToIeee(firstLBA, blockSize) << ")\n";
srs56940a697312010-01-28 21:10:52 -0500375 cout << "Last sector: " << lastLBA << " (at "
Roderick W. Smithaf39cb42013-08-06 15:23:46 -0400376 << BytesToIeee(lastLBA, blockSize) << ")\n";
srs56940a697312010-01-28 21:10:52 -0500377 size = (lastLBA - firstLBA + 1);
378 cout << "Partition size: " << size << " sectors ("
Roderick W. Smithaf39cb42013-08-06 15:23:46 -0400379 << BytesToIeee(size, blockSize) << ")\n";
srs56940a697312010-01-28 21:10:52 -0500380 cout << "Attribute flags: ";
381 cout.fill('0');
382 cout.width(16);
383 cout << hex;
384 cout << attributes << "\n";
385 cout << dec;
srs5694699941e2011-03-21 21:33:57 -0400386 cout << "Partition name: '" << GetDescription() << "'\n";
srs56940a697312010-01-28 21:10:52 -0500387 cout.fill(' ');
388 } // if
389} // GPTPart::ShowDetails()
390
391// Blank (delete) a single partition
392void GPTPart::BlankPartition(void) {
srs56946699b012010-02-04 00:55:30 -0500393 uniqueGUID.Zero();
394 partitionType.Zero();
srs56940a697312010-01-28 21:10:52 -0500395 firstLBA = 0;
396 lastLBA = 0;
397 attributes = 0;
Roderick W. Smith84aaff62014-02-17 16:17:11 -0500398 memset(name, 0, NAME_SIZE * sizeof( name[0]) );
srs56940a697312010-01-28 21:10:52 -0500399} // GPTPart::BlankPartition
400
401// Returns 1 if the two partitions overlap, 0 if they don't
402int GPTPart::DoTheyOverlap(const GPTPart & other) {
srs56940a697312010-01-28 21:10:52 -0500403 // Don't bother checking unless these are defined (both start and end points
404 // are 0 for undefined partitions, so just check the start points)
srs569464cbd172011-03-01 22:03:54 -0500405 return firstLBA && other.firstLBA &&
406 (firstLBA <= other.lastLBA) != (lastLBA < other.firstLBA);
srs56940a697312010-01-28 21:10:52 -0500407} // GPTPart::DoTheyOverlap()
408
srs56945a608532011-03-17 13:53:01 -0400409// Reverse the bytes of integral data types and of the UTF-16LE name;
410// used on big-endian systems.
srs56940a697312010-01-28 21:10:52 -0500411void GPTPart::ReversePartBytes(void) {
srs56945a608532011-03-17 13:53:01 -0400412 int i;
413
srs56940a697312010-01-28 21:10:52 -0500414 ReverseBytes(&firstLBA, 8);
415 ReverseBytes(&lastLBA, 8);
416 ReverseBytes(&attributes, 8);
Roderick W. Smith84aaff62014-02-17 16:17:11 -0500417 for (i = 0; i < NAME_SIZE; i ++ )
srs56945a608532011-03-17 13:53:01 -0400418 ReverseBytes(name + i, 2);
srs56940a697312010-01-28 21:10:52 -0500419} // GPTPart::ReverseBytes()
420
421/****************************************
422 * Functions requiring user interaction *
423 ****************************************/
424
srs56946699b012010-02-04 00:55:30 -0500425// Change the type code on the partition. Also changes the name if the original
426// name is the generic one for the partition type.
srs56940a697312010-01-28 21:10:52 -0500427void GPTPart::ChangeType(void) {
srs56945a608532011-03-17 13:53:01 -0400428 string line;
srs569464cbd172011-03-01 22:03:54 -0500429 int changeName;
srs569482f3f0b2010-09-22 10:50:24 -0400430 PartType tempType = (GUIDData) "00000000-0000-0000-0000-000000000000";
srs56940a697312010-01-28 21:10:52 -0500431
Roderick W. Smith84aaff62014-02-17 16:17:11 -0500432#ifdef USE_UTF16
srs56945a608532011-03-17 13:53:01 -0400433 changeName = (GetDescription() == GetUTypeName());
Roderick W. Smith84aaff62014-02-17 16:17:11 -0500434#else
435 changeName = (GetDescription() == GetTypeName());
436#endif
srs569455d92612010-03-07 22:16:07 -0500437
srs56946699b012010-02-04 00:55:30 -0500438 cout << "Current type is '" << GetTypeName() << "'\n";
srs569482f3f0b2010-09-22 10:50:24 -0400439 do {
srs56940741fa22013-01-09 12:55:40 -0500440 cout << "Hex code or GUID (L to show codes, Enter = " << hex << DEFAULT_GPT_TYPE << dec << "): ";
srs56945a608532011-03-17 13:53:01 -0400441 line = ReadString();
srs569482f3f0b2010-09-22 10:50:24 -0400442 if ((line[0] == 'L') || (line[0] == 'l')) {
srs56946699b012010-02-04 00:55:30 -0500443 partitionType.ShowAllTypes();
srs569482f3f0b2010-09-22 10:50:24 -0400444 } else {
srs56945a608532011-03-17 13:53:01 -0400445 if (line.length() == 0)
srs56940741fa22013-01-09 12:55:40 -0500446 tempType = DEFAULT_GPT_TYPE;
srs569482f3f0b2010-09-22 10:50:24 -0400447 else
448 tempType = line;
449 } // if/else
450 } while (tempType == (GUIDData) "00000000-0000-0000-0000-000000000000");
451 partitionType = tempType;
srs56946699b012010-02-04 00:55:30 -0500452 cout << "Changed type of partition to '" << partitionType.TypeName() << "'\n";
453 if (changeName) {
454 SetDefaultDescription();
455 } // if
srs56940a697312010-01-28 21:10:52 -0500456} // GPTPart::ChangeType()