Again =) Decided to use switch ( blahblah ) instead of if else statements.

* src/Device.cc (Read_Disk_Layout): Again =) Decided to use switch ( blahblah ) instead of if else statements.
This commit is contained in:
Bart Hakvoort 2004-10-11 12:55:33 +00:00
parent 014fb13d0b
commit 3dbaa30dba
2 changed files with 55 additions and 47 deletions

View File

@ -1,3 +1,7 @@
2004-10-11 Bart Hakvoort <gparted@users.sf.net>
* src/Device.cc (Read_Disk_Layout): Again =) Decided to use switch ( blahblah ) instead of if else statements.
2004-10-11 Bart Hakvoort <gparted@users.sf.net> 2004-10-11 Bart Hakvoort <gparted@users.sf.net>
* src/Device.cc (Read_Disk_Layout): some internal codechanges. Looks a bit cleaner now. * src/Device.cc (Read_Disk_Layout): some internal codechanges. Looks a bit cleaner now.

View File

@ -144,57 +144,61 @@ void Device::Read_Disk_Layout( bool deep_scan )
partition_temp .Reset( ) ; partition_temp .Reset( ) ;
part_path = this ->path + num_to_str( c_partition ->num ) ; part_path = this ->path + num_to_str( c_partition ->num ) ;
//PRIMARY or LOGICAL switch ( c_partition ->type )
if ( c_partition ->type == 0 || c_partition ->type == 1 )
{ {
if ( c_partition ->fs_type ) case PED_PARTITION_NORMAL:
temp = c_partition ->fs_type ->name ; case PED_PARTITION_LOGICAL:
else if ( c_partition ->fs_type )
{ temp = c_partition ->fs_type ->name ;
temp = "unknown" ; else
this ->error = _( "Unable to detect filesystem! Possible reasons are:" ) ; {
this ->error += "\n-"; temp = "unknown" ;
this ->error += _( "The filesystem is damaged" ) ; this ->error = _( "Unable to detect filesystem! Possible reasons are:" ) ;
this ->error += "\n-" ; this ->error += "\n-";
this ->error += _( "The filesystem is unknown to libparted" ) ; this ->error += _( "The filesystem is damaged" ) ;
this ->error += "\n-"; this ->error += "\n-" ;
this ->error += _( "There is no filesystem available (unformatted)" ) ; this ->error += _( "The filesystem is unknown to libparted" ) ;
this ->error += "\n-";
} this ->error += _( "There is no filesystem available (unformatted)" ) ;
partition_temp.Set( part_path,
c_partition ->num, }
c_partition ->type == 0 ? GParted::PRIMARY : GParted::LOGICAL , partition_temp.Set( part_path,
temp, c_partition ->geom .start, c_partition ->num,
c_partition ->geom .end, c_partition ->type == 0 ? GParted::PRIMARY : GParted::LOGICAL ,
c_partition ->type , temp, c_partition ->geom .start,
ped_partition_is_busy( c_partition ) ); c_partition ->geom .end,
c_partition ->type ,
if ( deep_scan ) ped_partition_is_busy( c_partition ) );
partition_temp .Set_Used( Get_Used_Sectors( c_partition, part_path ) ) ;
if ( deep_scan )
partition_temp .flags = Get_Flags( c_partition ) ; partition_temp .Set_Used( Get_Used_Sectors( c_partition, part_path ) ) ;
partition_temp .error = this ->error ;//most likely useless, but paranoia me leaves it here.. =)
} partition_temp .flags = Get_Flags( c_partition ) ;
partition_temp .error = this ->error ;//most likely useless, but paranoia me leaves it here.. =)
break ;
//EXTENDED
else if ( c_partition ->type == 2 )
{
partition_temp.Set( part_path ,
c_partition ->num ,
GParted::EXTENDED ,
"extended" ,
c_partition ->geom .start ,
c_partition ->geom .end ,
false ,
ped_partition_is_busy( c_partition ) );
partition_temp .flags = Get_Flags( c_partition ) ; case PED_PARTITION_EXTENDED:
} partition_temp.Set( part_path ,
c_partition ->num ,
GParted::EXTENDED ,
"extended" ,
c_partition ->geom .start ,
c_partition ->geom .end ,
false ,
ped_partition_is_busy( c_partition ) );
partition_temp .flags = Get_Flags( c_partition ) ;
break ;
//FREESPACE
else if ( (c_partition ->type == 4 || c_partition ->type == 5) && (c_partition ->geom .end - c_partition ->geom .start) > MEGABYTE ) case PED_PARTITION_FREESPACE:
{ partition_temp.Set_Unallocated( c_partition ->geom .start, c_partition ->geom .end, c_partition ->type == 4 ? false : true );
partition_temp.Set_Unallocated( c_partition ->geom .start, c_partition ->geom .end, c_partition ->type == 4 ? false : true ); break ;
case PED_PARTITION_METADATA:
break;
} }
if ( partition_temp .sector_start != -1 ) //paranoia check for unallocted space < 1 MB.. if ( partition_temp .sector_start != -1 ) //paranoia check for unallocted space < 1 MB..