From d61583599b1c4064db5e8e4373f7fcfdd4abf327 Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Wed, 5 Apr 2006 13:47:53 +0000 Subject: [PATCH] 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 --- ChangeLog | 7 +++++ src/Dialog_Partition_Resize_Move.cc | 40 +++++++++++++++++++++-------- src/GParted_Core.cc | 4 ++- src/Win_GParted.cc | 2 +- src/hfs.cc | 3 ++- 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0fabe307..66a9075a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-04-05 Bart Hakvoort + + * 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 * src/DialogManageFlags.cc: disabled resizing of this dialog diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc index 27c36b0a..92036b07 100644 --- a/src/Dialog_Partition_Resize_Move.cc +++ b/src/Dialog_Partition_Resize_Move.cc @@ -109,30 +109,44 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vectorset_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::vectorset_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ), Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 219b9b5a..94404359 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -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 ) ) { diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index 7a05a89f..063dd4fb 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -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 diff --git a/src/hfs.cc b/src/hfs.cc index 8b46eb01..4c2d8af5 100644 --- a/src/hfs.cc +++ b/src/hfs.cc @@ -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 ;