From 10e8f3338d76e74c5fba22ff6c86888a67b99ae9 Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Wed, 15 Dec 2004 20:43:58 +0000 Subject: [PATCH] :get_fs now returns a const reference. in copy and resizedialog * Gparted_Core::get_fs now returns a const reference. * in copy and resizedialog filesystems with MAX set now have a max size of MAX - one cylinder . --- ChangeLog | 5 +++++ include/Dialog_Base_Partition.h | 1 + include/Dialog_Partition_Copy.h | 2 +- include/Dialog_Partition_Resize_Move.h | 2 -- include/GParted_Core.h | 2 +- src/Dialog_Partition_Copy.cc | 11 ++++++++--- src/Dialog_Partition_Resize_Move.cc | 5 +++-- src/GParted_Core.cc | 2 +- src/Win_GParted.cc | 2 +- 9 files changed, 21 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e6b0adc..50315e7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-12-15 Bart Hakvoort + + * Gparted_Core::get_fs now returns a const reference. + * in copy and resizedialog filesystems with MAX set now have a max size of MAX - one cylinder . + 2004-12-15 Bart Hakvoort * (all filesystem classes): fixed bug with thousand separator (#161362). diff --git a/include/Dialog_Base_Partition.h b/include/Dialog_Base_Partition.h index 0f1f1d6e..0170bb41 100644 --- a/include/Dialog_Base_Partition.h +++ b/include/Dialog_Base_Partition.h @@ -81,6 +81,7 @@ protected: bool fixed_start, GRIP ; double before_value ; FS fs ; + short BUF ; //used in resize and copy ( safety reasons ) private: void Check_Change() ; diff --git a/include/Dialog_Partition_Copy.h b/include/Dialog_Partition_Copy.h index 8a9d8a94..34f6f237 100644 --- a/include/Dialog_Partition_Copy.h +++ b/include/Dialog_Partition_Copy.h @@ -26,7 +26,7 @@ namespace GParted class Dialog_Partition_Copy : public Dialog_Base_Partition { public: - Dialog_Partition_Copy( std::vector FILESYSTEMS ) ; + Dialog_Partition_Copy( std::vector FILESYSTEMS, Sector cylinder_size ) ; void Set_Data( const Partition & selected_partition, const Partition & copied_partition ); Partition Get_New_Partition( ) ; diff --git a/include/Dialog_Partition_Resize_Move.h b/include/Dialog_Partition_Resize_Move.h index 34b2136a..4c2ad0a0 100644 --- a/include/Dialog_Partition_Resize_Move.h +++ b/include/Dialog_Partition_Resize_Move.h @@ -33,8 +33,6 @@ private: void Resize_Move_Normal( const std::vector & partitions ) ; void Resize_Move_Extended( const std::vector & partitions ) ; - short BUF ; //added to the min. size a filesystem can be..( safety reasons ) - }; } //GParted diff --git a/include/GParted_Core.h b/include/GParted_Core.h index a2531a27..7aadb711 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -57,7 +57,7 @@ public: bool Set_Disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ; - std::vector get_fs( ) ; + const std::vector & get_fs( ) const ; Glib::RefPtr get_textbuffer( ) ; private: diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc index dcf0cd9f..56b8b454 100644 --- a/src/Dialog_Partition_Copy.cc +++ b/src/Dialog_Partition_Copy.cc @@ -20,10 +20,16 @@ namespace GParted { -Dialog_Partition_Copy::Dialog_Partition_Copy( std::vector FILESYSTEMS ) +Dialog_Partition_Copy::Dialog_Partition_Copy( std::vector FILESYSTEMS, Sector cylinder_size ) { this ->FILESYSTEMS = FILESYSTEMS ; + //some disk have a small cylindersize, for safetyreasons i keep this size at >=1 + if ( cylinder_size < 2048 ) + cylinder_size = 2048 ; + + BUF = Sector_To_MB( cylinder_size ) ; + Set_Resizer( false ) ; Set_Confirm_Button( PASTE ) ; } @@ -50,8 +56,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons frame_resizer_base ->set_x_end( ( Round( (double) (copied_partition .sector_end - copied_partition .sector_start) / ( (double)total_length/500) )) ) ; frame_resizer_base ->set_used( Round( (double) copied_partition .sectors_used / ( (double)total_length/500) ) ) ; - if ( ! fs .MAX ) - fs .MAX = TOTAL_MB ; + fs .MAX = ( ! fs .MAX || fs .MAX > TOTAL_MB ) ? TOTAL_MB : fs .MAX -= BUF ; fs .MIN = copied_partition .Get_Length_MB( ) +1 ; diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc index 6ef2e4d1..aa90c52d 100644 --- a/src/Dialog_Partition_Resize_Move.cc +++ b/src/Dialog_Partition_Resize_Move.cc @@ -129,8 +129,9 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector TOTAL_MB ) - fs .MAX = TOTAL_MB ; + //if ( ! fs .MAX || fs .MAX > TOTAL_MB ) + // fs .MAX = TOTAL_MB ; + fs .MAX = ( ! fs .MAX || fs .MAX > TOTAL_MB ) ? TOTAL_MB : fs .MAX -= BUF/2 ; //set values of spinbutton_before if ( ! fixed_start ) diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index b2ecc363..284bae0d 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -470,7 +470,7 @@ bool GParted_Core::Set_Disklabel( const Glib::ustring & device_path, const Glib: return return_value ; } -std::vector GParted_Core::get_fs( ) +const std::vector & GParted_Core::get_fs( ) const { return FILESYSTEMS ; } diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index 14b92162..8b5e835e 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -927,7 +927,7 @@ void Win_GParted::activate_paste() { if ( ! max_amount_prim_reached( ) ) { - Dialog_Partition_Copy dialog( gparted_core .get_fs( ) ) ; + Dialog_Partition_Copy dialog( gparted_core .get_fs( ), devices[ current_device ] .heads * devices[ current_device ] .sectors ) ; copied_partition .error .clear( ) ; //we don't need the errors of the source partition. dialog .Set_Data( selected_partition, copied_partition ) ; dialog .set_transient_for( *this );