added support for shrinking hfs filesystems

* src/Dialog_Partition_Resize_Move.cc,
  src/GParted_Core.cc,
  src/Win_GParted.cc,
  src/hfs.cc: added support for shrinking hfs filesystems
This commit is contained in:
Bart Hakvoort 2006-04-05 13:47:53 +00:00
parent b86d290607
commit d61583599b
5 changed files with 42 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2006-04-05 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/Dialog_Partition_Resize_Move.cc,
src/GParted_Core.cc,
src/Win_GParted.cc,
src/hfs.cc: added support for shrinking hfs filesystems
2006-04-05 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/DialogManageFlags.cc: disabled resizing of this dialog

View File

@ -109,30 +109,44 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
frame_resizer_base ->set_x_end(
Utils::round( selected_partition .get_length() / ( total_length / 500.00 ) ) + frame_resizer_base ->get_x_start() ) ;
frame_resizer_base ->set_used( Utils::round( selected_partition.sectors_used / ( total_length / 500.00 ) ) ) ;
//set MIN
if ( fs .shrink )
{
//since some filesystems have lower limits we need to check for this
if ( selected_partition .sectors_used > fs .MIN )
fs .MIN = selected_partition .sectors_used ;
//if fs. MIN is 0 here (means used == 0 as well) it's safe to have BUF / 2
fs .MIN += fs .MIN ? BUF : BUF/2 ;
//in certain (rare) cases fs .MIN is a bit too high...
//in certain (rare) cases fs .MIN is (now) larger than 'selected_partition'..
if ( fs .MIN > selected_partition .get_length() )
fs .MIN = selected_partition .get_length() ;
}
else //only grow..
else
fs .MIN = selected_partition .get_length() ;
fs .MAX = ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBIBYTE) ) ? ( TOTAL_MB * MEBIBYTE ) : fs .MAX -= BUF/2 ;
//set MAX
if ( fs .grow )
{
if ( ! fs .MAX || fs .MAX > (TOTAL_MB * MEBIBYTE) )
fs .MAX = TOTAL_MB * MEBIBYTE ;
else
fs .MAX -= BUF/2 ;
}
else
fs .MAX = selected_partition .get_length() ;
//set values of spinbutton_before
if ( ! fixed_start )
{
spinbutton_before .set_range( 0, TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ) ) ;
spinbutton_before .set_value( Utils::round( Utils::sector_to_unit( previous, GParted::UNIT_MIB ) ) ) ;
spinbutton_before .set_range(
0,
TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ) ) ;
spinbutton_before .set_value(
Utils::round( Utils::sector_to_unit( previous, GParted::UNIT_MIB ) ) ) ;
}
//set values of spinbutton_size
@ -143,8 +157,12 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
Utils::round( Utils::sector_to_unit( selected_partition .get_length(), GParted::UNIT_MIB ) ) ) ;
//set values of spinbutton_after
spinbutton_after .set_range( 0, TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ) ) ;
spinbutton_after .set_value( Utils::round( Utils::sector_to_unit( next, GParted::UNIT_MIB ) ) ) ;
Sector after_min = ( ! fs .grow && ! fs .move ) ? next : 0 ;
spinbutton_after .set_range(
Utils::round( Utils::sector_to_unit( after_min, GParted::UNIT_MIB ) ),
TOTAL_MB - Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ) ) ;
spinbutton_after .set_value(
Utils::round( Utils::sector_to_unit( next, GParted::UNIT_MIB ) ) ) ;
frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;

View File

@ -731,7 +731,9 @@ bool GParted_Core::resize( const Device & device,
set_proper_filesystem( partition_new .filesystem ) ;
//resize using libparted..
if ( get_fs( partition_old .filesystem ) .grow == GParted::FS::LIBPARTED )
if ( get_fs( partition_old .filesystem ) .grow == GParted::FS::LIBPARTED ||
get_fs( partition_old .filesystem ) .shrink == GParted::FS::LIBPARTED ||
get_fs( partition_old .filesystem ) .move == GParted::FS::LIBPARTED )
{
if ( p_filesystem && p_filesystem ->Check_Repair( partition_new, operation_details ) )
{

View File

@ -817,7 +817,7 @@ void Win_GParted::set_valid_operations()
allow_format( true ) ;
//find out if resizing/moving is possible
if ( (fs .grow || fs .shrink ) && ! devices[ current_device ] .readonly )
if ( (fs .grow || fs .shrink || fs .move ) && ! devices[ current_device ] .readonly )
allow_resize( true ) ;
//only allow copying of real partitions

View File

@ -27,7 +27,8 @@ FS hfs::get_filesystem_support()
fs .filesystem = GParted::FS_HFS ;
fs .read = GParted::FS::LIBPARTED; //provided by libparted
fs .read = GParted::FS::LIBPARTED ;
fs .shrink = GParted::FS::LIBPARTED ;
if ( ! Glib::find_program_in_path( "hformat" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;