From 89a42f3f07644cbb60d283b7308888741deb7ffc Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Tue, 1 Aug 2006 12:47:03 +0000 Subject: [PATCH] added get_sector() use new Partition::get_sector() * include/Partition.h, src/Partition.cc: added get_sector() * src/GParted_Core.cc: use new Partition::get_sector() --- ChangeLog | 6 ++++++ include/Partition.h | 1 + src/GParted_Core.cc | 41 +++++++++++------------------------------ src/Partition.cc | 5 +++++ 4 files changed, 23 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index a720b008..295bd1d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-08-01 Bart Hakvoort + + * include/Partition.h, + src/Partition.cc: added get_sector() + * src/GParted_Core.cc: use new Partition::get_sector() + 2006-08-01 Bart Hakvoort * src/Dialog_Partition_Copy.cc, diff --git a/include/Partition.h b/include/Partition.h index 7c33f26e..9bb83e52 100644 --- a/include/Partition.h +++ b/include/Partition.h @@ -86,6 +86,7 @@ public: Glib::ustring get_mountpoint() const ; void clear_mountpoints() ; std::vector get_mountpoints() const ; + Sector get_sector() const ; bool operator==( const Partition & partition ) const ; bool operator!=( const Partition & partition ) const ; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 410868fd..238cf901 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -295,9 +295,8 @@ bool GParted_Core::apply_operation_to_disk( Operation * operation ) if ( open_device_and_disk( operation ->partition_original .device_path ) ) { - lp_partition = ped_disk_get_partition_by_sector( - lp_disk, - (operation ->partition_original .sector_end + operation ->partition_original .sector_start) / 2 ) ; + lp_partition = ped_disk_get_partition_by_sector( lp_disk, + operation ->partition_original .get_sector() ) ; if ( lp_partition ) { @@ -400,9 +399,7 @@ bool GParted_Core::toggle_flag( const Partition & partition, const Glib::ustring if ( partition .type == GParted::TYPE_EXTENDED ) lp_partition = ped_disk_extended_partition( lp_disk ) ; else - lp_partition = ped_disk_get_partition_by_sector( - lp_disk, - (partition .sector_end + partition .sector_start) / 2 ) ; + lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ; if ( lp_partition ) { @@ -467,9 +464,7 @@ std::map GParted_Core::get_available_flags( const Partition if ( partition .type == GParted::TYPE_EXTENDED ) lp_partition = ped_disk_extended_partition( lp_disk ) ; else - lp_partition = ped_disk_get_partition_by_sector( - lp_disk, - (partition .sector_end + partition .sector_start) / 2 ) ; + lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ; if ( lp_partition ) { @@ -907,9 +902,7 @@ void GParted_Core::LP_set_used_sectors( Partition & partition ) if ( lp_disk ) { - lp_partition = ped_disk_get_partition_by_sector( - lp_disk, - (partition .sector_end + partition .sector_start) / 2 ) ; + lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ; if ( lp_partition ) { @@ -1109,9 +1102,7 @@ bool GParted_Core::Delete( const Partition & partition, std::vectorgeom ); @@ -1520,9 +1509,7 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old, if ( partition_old .type == GParted::TYPE_EXTENDED ) lp_partition = ped_disk_extended_partition( lp_disk ) ; else - lp_partition = ped_disk_get_partition_by_sector( - lp_disk, - (partition_old .sector_end + partition_old .sector_start) / 2 ) ; + lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition_old .get_sector() ) ; if ( lp_partition ) { @@ -1854,9 +1841,7 @@ bool GParted_Core::set_partition_type( const Partition & partition, if ( fs_type ) { - lp_partition = ped_disk_get_partition_by_sector( - lp_disk, - (partition .sector_end + partition .sector_start) / 2 ) ; + lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ; if ( lp_partition && ped_partition_set_system( lp_partition, fs_type ) && commit() ) return_value = wait_for_node( partition .get_path() ) ; @@ -1925,9 +1910,7 @@ bool GParted_Core::calculate_exact_geom( const Partition & partition_old, if ( partition_old .type == GParted::TYPE_EXTENDED ) lp_partition = ped_disk_extended_partition( lp_disk ) ; else - lp_partition = ped_disk_get_partition_by_sector( - lp_disk, - (partition_old .sector_end + partition_old .sector_start) / 2 ) ; + lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition_old .get_sector() ) ; if ( lp_partition ) { @@ -2029,9 +2012,7 @@ bool GParted_Core::erase_filesystem_signatures( const Partition & partition ) if ( open_device_and_disk( partition .device_path ) ) { - lp_partition = ped_disk_get_partition_by_sector( - lp_disk, - (partition .sector_end + partition .sector_start) / 2 ) ; + lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ; if ( lp_partition && ped_file_system_clobber( & lp_partition ->geom ) ) { diff --git a/src/Partition.cc b/src/Partition.cc index 2470c321..e598895f 100644 --- a/src/Partition.cc +++ b/src/Partition.cc @@ -210,6 +210,11 @@ std::vector Partition::get_mountpoints() const return mountpoints ; } +Sector Partition::get_sector() const +{ + return (sector_start + sector_end) / 2 ; +} + void Partition::clear_mountpoints() { mountpoints .clear() ;