Convert file system maximum from sector to byte value

This commit is contained in:
Curtis Gedak 2010-03-16 13:25:58 -06:00
parent 40d7dbac4b
commit f9f603256e
7 changed files with 22 additions and 23 deletions

View File

@ -118,7 +118,7 @@ struct FS
Support copy ;
Byte_Value MIN ;
Sector MAX ;
Byte_Value MAX ;
FS()
{

View File

@ -99,9 +99,9 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
copied_partition .sectors_used, GParted::UNIT_MIB ) / (TOTAL_MB/500.00) ) ) ;
if ( fs .grow )
fs .MAX = ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBIBYTE) ) ? (TOTAL_MB * MEBIBYTE) : fs .MAX - BUF ;
fs .MAX = ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBI_FACTOR) ) ? (TOTAL_MB * MEBI_FACTOR) : fs .MAX - (BUF * DEFAULT_SECTOR_SIZE) ;
else
fs .MAX = copied_partition .get_length() ;
fs .MAX = copied_partition .get_length() * DEFAULT_SECTOR_SIZE ;
if ( fs .filesystem == GParted::FS_XFS ) //bit hackisch, but most effective, since it's a unique situation
@ -117,7 +117,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
//set values of spinbutton_size
spinbutton_size .set_range(
Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
spinbutton_size .set_value( COPIED_LENGTH_MB ) ;
//set values of spinbutton_after
@ -126,12 +126,12 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
GRIP = false ;
frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
Utils::round( fs .MAX / (MB_PER_PIXEL * MEBI_FACTOR) ) ) ;
//set contents of label_minmax
Set_MinMax_Text(
Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
this ->selected_partition = copied_partition ;

View File

@ -151,7 +151,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
//set spinbuttons initial values
spinbutton_after .set_value( 0 ) ;
spinbutton_size .set_value( Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
spinbutton_size .set_value( Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
spinbutton_before .set_value( 0 ) ;
//euhrm, this wil only happen when there's a very small free space (usually the effect of a bad partitionmanager)
@ -260,25 +260,24 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
if ( selected_partition .get_length() < (fs .MIN /DEFAULT_SECTOR_SIZE) )
fs .MIN = selected_partition .get_length() * DEFAULT_SECTOR_SIZE ;
fs .MAX = ( fs .MAX && ( fs .MAX - cylinder_size ) < (TOTAL_MB * MEBIBYTE) ) ?
fs .MAX - cylinder_size : TOTAL_MB * MEBIBYTE ;
fs .MAX = ( fs .MAX && ( fs .MAX < (TOTAL_MB * MEBI_FACTOR) ) ) ? fs .MAX : (TOTAL_MB * MEBI_FACTOR) ;
frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
Utils::round( fs .MAX / (MB_PER_PIXEL * MEBI_FACTOR) ) ) ;
//set new spinbutton ranges
spinbutton_before .set_range(
0, TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
spinbutton_size .set_range(
Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
spinbutton_after .set_range(
0, TOTAL_MB - Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
//set contents of label_minmax
Set_MinMax_Text(
Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
}
//set fitting resizer colors

View File

@ -133,13 +133,13 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
//set MAX
if ( fs .grow )
{
if ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBIBYTE) )
fs .MAX = TOTAL_MB * MEBIBYTE ;
if ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBI_FACTOR) )
fs .MAX = TOTAL_MB * MEBI_FACTOR ;
else
fs .MAX -= BUF/2 ;
fs .MAX -= (BUF/2 * DEFAULT_SECTOR_SIZE) ;
}
else
fs .MAX = selected_partition .get_length() ;
fs .MAX = selected_partition .get_length() * DEFAULT_SECTOR_SIZE ;
//set values of spinbutton_before
@ -155,7 +155,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
//set values of spinbutton_size
spinbutton_size .set_range(
Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
spinbutton_size .set_value(
Utils::round( Utils::sector_to_unit( selected_partition .get_length(), GParted::UNIT_MIB ) ) ) ;
@ -168,12 +168,12 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
Utils::round( Utils::sector_to_unit( next, GParted::UNIT_MIB ) ) ) ;
frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBI_FACTOR) ),
Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
Utils::round( fs .MAX / (MB_PER_PIXEL * MEBI_FACTOR) ) ) ;
//set contents of label_minmax
Set_MinMax_Text(
Utils::round( Utils::sector_to_unit( (fs .MIN / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ),
Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
Utils::round( Utils::sector_to_unit( (fs .MAX / DEFAULT_SECTOR_SIZE), GParted::UNIT_MIB ) ) ) ;
}
void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector<Partition> & partitions )

View File

@ -1641,7 +1641,7 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
fs = gparted_core .get_fs( new_fs ) ;
if ( ( selected_partition .get_length() < (fs .MIN / DEFAULT_SECTOR_SIZE) ) ||
( fs .MAX && selected_partition .get_length() > fs .MAX ) )
( fs .MAX && selected_partition .get_length() > (fs .MAX / DEFAULT_SECTOR_SIZE) ) )
{
Gtk::MessageDialog dialog( *this,
String::ucompose( _("Cannot format this file system to %1."),
@ -1660,7 +1660,7 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
dialog .set_secondary_text( String::ucompose(
_( "A partition with a %1 file system has a maximum size of %2."),
Utils::get_filesystem_string( new_fs ),
Utils::format_size( fs .MAX ) ) );
Utils::format_size( (fs .MAX / DEFAULT_SECTOR_SIZE) ) ) );
dialog .run() ;
return ;

View File

@ -57,7 +57,7 @@ FS fat16::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
fs .MIN = 16 * MEBI_FACTOR ;
fs .MAX = 4096 * MEBIBYTE ;
fs .MAX = (4096 - 1) * MEBI_FACTOR ; //Maximum seems to be just less than 4096 MiB
return fs ;
}

View File

@ -43,7 +43,7 @@ FS hfs::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
fs .move = GParted::FS::GPARTED ;
fs .MAX = 2048 * MEBIBYTE ;
fs .MAX = 2048 * MEBI_FACTOR ;
return fs ;
}