From fed2595d6dab09499e3e836b78adce24819dd35d Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Fri, 4 Nov 2016 13:02:28 +0000 Subject: [PATCH] Rename file and class to CopyBlocks (#775932) Files were named Block_Copy and the class was named block_copy. Change to the primary naming convention of CamelCase class name and matching file names. Also make CopyBlocks::copy_block() a private method as it is only used internally within the class. Bug 775932 - Refactor mostly applying of operations --- AUTHORS | 2 +- include/{Copy_Blocks.h => CopyBlocks.h} | 32 ++++++++++--------- include/Makefile.am | 2 +- po/POTFILES.in | 2 +- src/{Copy_Blocks.cc => CopyBlocks.cc} | 40 +++++++++++------------ src/GParted_Core.cc | 42 ++++++++++++------------- src/Makefile.am | 2 +- 7 files changed, 62 insertions(+), 60 deletions(-) rename include/{Copy_Blocks.h => CopyBlocks.h} (73%) rename src/{Copy_Blocks.cc => CopyBlocks.cc} (88%) diff --git a/AUTHORS b/AUTHORS index c864adcc..2322be4c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -112,7 +112,7 @@ Phillip Susi * Wrote patch to display dialog pop-up for libparted exceptions * Wrote patch set to refactor code enabling commands to be spawned asynchronously * Created PipeCapture.h, PipeCapture.cc to capture spawned command output - * Created Copy_Blocks.h, Copy_Blocks.cc to copy blocks of disk data + * Created CopyBlocks.h, CopyBlocks.cc to copy blocks of disk data Rogier Goossens * Wrote patch to support changing file system UUIDs. diff --git a/include/Copy_Blocks.h b/include/CopyBlocks.h similarity index 73% rename from include/Copy_Blocks.h rename to include/CopyBlocks.h index 17d9fdd9..99305acc 100644 --- a/include/Copy_Blocks.h +++ b/include/CopyBlocks.h @@ -14,8 +14,8 @@ * along with this program; if not, see . */ -#ifndef GPARTED_COPY_BLOCKS_H -#define GPARTED_COPY_BLOCKS_H +#ifndef GPARTED_COPYBLOCKS_H +#define GPARTED_COPYBLOCKS_H #include "../include/OperationDetail.h" #include "../include/Utils.h" @@ -25,7 +25,8 @@ namespace GParted { -class copy_blocks { +class CopyBlocks +{ const Glib::ustring & src_device; const Glib::ustring & dst_device; Byte_Value length; @@ -45,22 +46,23 @@ class copy_blocks { bool cancel; bool cancel_safe; void set_cancel( bool force ); + void copy_block(); + public: bool set_progress_info(); - copy_blocks( const Glib::ustring & in_src_device, - const Glib::ustring & in_dst_device, - Sector src_start, - Sector dst_start, - Byte_Value in_length, - Byte_Value in_blocksize, - OperationDetail & in_operationdetail, - Byte_Value & in_total_done, - Byte_Value in_total_length, - bool cancel_safe ); + CopyBlocks( const Glib::ustring & in_src_device, + const Glib::ustring & in_dst_device, + Sector src_start, + Sector dst_start, + Byte_Value in_length, + Byte_Value in_blocksize, + OperationDetail & in_operationdetail, + Byte_Value & in_total_done, + Byte_Value in_total_length, + bool cancel_safe ); bool copy(); - void copy_block(); }; } // namespace GParted -#endif /* GPARTED_COPY_BLOCKS_H */ +#endif /* GPARTED_COPYBLOCKS_H */ diff --git a/include/Makefile.am b/include/Makefile.am index c6aa6d81..6f0a851c 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,7 +2,7 @@ gparted_includedir = $(pkgincludedir) EXTRA_DIST = \ BlockSpecial.h \ - Copy_Blocks.h \ + CopyBlocks.h \ DMRaid.h \ Device.h \ DialogFeatures.h \ diff --git a/po/POTFILES.in b/po/POTFILES.in index 10cdb7ae..51841dd2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -4,7 +4,7 @@ gparted.appdata.xml.in gparted.desktop.in.in include/Utils.h src/BlockSpecial.cc -src/Copy_Blocks.cc +src/CopyBlocks.cc src/Dialog_Base_Partition.cc src/Dialog_Disklabel.cc src/Dialog_FileSystem_Label.cc diff --git a/src/Copy_Blocks.cc b/src/CopyBlocks.cc similarity index 88% rename from src/Copy_Blocks.cc rename to src/CopyBlocks.cc index e9e7587f..f0aa0de0 100644 --- a/src/Copy_Blocks.cc +++ b/src/CopyBlocks.cc @@ -16,7 +16,7 @@ * along with this program; if not, see . */ -#include "../include/Copy_Blocks.h" +#include "../include/CopyBlocks.h" #include "../include/OperationDetail.h" #include "../include/ProgressBar.h" #include "../include/Utils.h" @@ -27,22 +27,22 @@ namespace GParted { -void copy_blocks::set_cancel( bool force ) +void CopyBlocks::set_cancel( bool force ) { if ( force || cancel_safe ) cancel = true; } -copy_blocks::copy_blocks( const Glib::ustring & in_src_device, - const Glib::ustring & in_dst_device, - Sector src_start, - Sector dst_start, - Byte_Value in_length, - Byte_Value in_blocksize, - OperationDetail & in_operationdetail, - Byte_Value & in_total_done, - Byte_Value in_total_length, - bool in_cancel_safe) : +CopyBlocks::CopyBlocks( const Glib::ustring & in_src_device, + const Glib::ustring & in_dst_device, + Sector src_start, + Sector dst_start, + Byte_Value in_length, + Byte_Value in_blocksize, + OperationDetail & in_operationdetail, + Byte_Value & in_total_done, + Byte_Value in_total_length, + bool in_cancel_safe) : src_device( in_src_device ), dst_device ( in_dst_device ), length ( in_length ), @@ -56,12 +56,12 @@ copy_blocks::copy_blocks( const Glib::ustring & in_src_device, cancel_safe ( in_cancel_safe ) { operationdetail.signal_cancel.connect( - sigc::mem_fun(*this, ©_blocks::set_cancel)); + sigc::mem_fun(*this, &CopyBlocks::set_cancel)); if (operationdetail.cancelflag) set_cancel( operationdetail.cancelflag == 2 ); } -bool copy_blocks::set_progress_info() +bool CopyBlocks::set_progress_info() { Byte_Value done = llabs(this->done); operationdetail.run_progressbar( (double)(total_done+done), (double)total_length, PROGRESSBAR_TEXT_COPY_BYTES ); @@ -74,7 +74,7 @@ bool copy_blocks::set_progress_info() return false; } -static bool mainquit(copy_blocks *cb) +static bool mainquit( CopyBlocks *cb ) { while ( Gtk::Main::events_pending() ) Gtk::Main::iteration(); @@ -84,11 +84,11 @@ static bool mainquit(copy_blocks *cb) static gboolean _set_progress_info( gpointer data ) { - copy_blocks *cb = (copy_blocks *)data; + CopyBlocks *cb = (CopyBlocks *)data; return cb->set_progress_info(); } -void copy_blocks::copy_thread() +void CopyBlocks::copy_thread() { if ( ped_device_open( lp_device_src ) && (lp_device_src == lp_device_dst || ped_device_open( lp_device_dst ) ) ) @@ -146,7 +146,7 @@ void copy_blocks::copy_thread() g_idle_add( (GSourceFunc)mainquit, this ); } -bool copy_blocks::copy() +bool CopyBlocks::copy() { if ( blocksize > length ) blocksize = length; @@ -167,7 +167,7 @@ bool copy_blocks::copy() buf = static_cast( malloc( llabs( blocksize ) ) ); if ( buf ) { - Glib::Thread::create( sigc::mem_fun( *this, ©_blocks::copy_thread ), + Glib::Thread::create( sigc::mem_fun( *this, &CopyBlocks::copy_thread ), false ); Gtk::Main::run(); @@ -198,7 +198,7 @@ bool copy_blocks::copy() return success; } -void copy_blocks::copy_block() +void CopyBlocks::copy_block() { Byte_Value sector_size_src = lp_device_src ->sector_size; Byte_Value sector_size_dst = lp_device_dst ->sector_size; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 0fabff48..55cd52d8 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -48,7 +48,7 @@ #include "../include/hfsplus.h" #include "../include/reiser4.h" #include "../include/ufs.h" -#include "../include/Copy_Blocks.h" +#include "../include/CopyBlocks.h" #include #include @@ -2997,16 +2997,16 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device, benchmark_blocksize <= N ) { timer .reset() ; - succes = copy_blocks( src_device, - dst_device, - offset_read + (done / src_sector_size), - offset_write + (done / dst_sector_size), - N, - benchmark_blocksize, - operationdetail .get_last_child(), - total_done, - src_length, - cancel_safe ).copy(); + succes = CopyBlocks( src_device, + dst_device, + offset_read + (done / src_sector_size), + offset_write + (done / dst_sector_size), + N, + benchmark_blocksize, + operationdetail .get_last_child(), + total_done, + src_length, + cancel_safe ).copy(); timer.stop() ; operationdetail .get_last_child() .get_last_child() .add_child( OperationDetail( @@ -3033,16 +3033,16 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device, STATUS_NONE ) ) ; if ( succes && llabs( done ) < src_length ) - succes = copy_blocks( src_device, - dst_device, - src_start + ((done > 0 ? done : 0) / src_sector_size), - dst_start + ((done > 0 ? done : 0) / dst_sector_size), - src_length - llabs( done ), - optimal_blocksize, - operationdetail, - total_done, - src_length, - cancel_safe ).copy(); + succes = CopyBlocks( src_device, + dst_device, + src_start + ((done > 0 ? done : 0) / src_sector_size), + dst_start + ((done > 0 ? done : 0) / dst_sector_size), + src_length - llabs( done ), + optimal_blocksize, + operationdetail, + total_done, + src_length, + cancel_safe ).copy(); operationdetail .add_child( OperationDetail( String::ucompose( /*TO TRANSLATORS: looks like 1.00 MiB (1048576 B) copied */ diff --git a/src/Makefile.am b/src/Makefile.am index a1ae501e..23a0b1ee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,7 +13,7 @@ sbin_PROGRAMS = gpartedbin gpartedbin_SOURCES = \ BlockSpecial.cc \ - Copy_Blocks.cc \ + CopyBlocks.cc \ DMRaid.cc \ Device.cc \ DialogFeatures.cc \