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
This commit is contained in:
Mike Fleetwood 2016-11-04 13:02:28 +00:00 committed by Curtis Gedak
parent a5f2c9937b
commit fed2595d6d
7 changed files with 62 additions and 60 deletions

View File

@ -112,7 +112,7 @@ Phillip Susi <psusi@cfl.rr.com>
* Wrote patch to display dialog pop-up for libparted exceptions * Wrote patch to display dialog pop-up for libparted exceptions
* Wrote patch set to refactor code enabling commands to be spawned asynchronously * Wrote patch set to refactor code enabling commands to be spawned asynchronously
* Created PipeCapture.h, PipeCapture.cc to capture spawned command output * 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 <goossens.rogier@gmail.com> Rogier Goossens <goossens.rogier@gmail.com>
* Wrote patch to support changing file system UUIDs. * Wrote patch to support changing file system UUIDs.

View File

@ -14,8 +14,8 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef GPARTED_COPY_BLOCKS_H #ifndef GPARTED_COPYBLOCKS_H
#define GPARTED_COPY_BLOCKS_H #define GPARTED_COPYBLOCKS_H
#include "../include/OperationDetail.h" #include "../include/OperationDetail.h"
#include "../include/Utils.h" #include "../include/Utils.h"
@ -25,7 +25,8 @@
namespace GParted { namespace GParted {
class copy_blocks { class CopyBlocks
{
const Glib::ustring & src_device; const Glib::ustring & src_device;
const Glib::ustring & dst_device; const Glib::ustring & dst_device;
Byte_Value length; Byte_Value length;
@ -45,22 +46,23 @@ class copy_blocks {
bool cancel; bool cancel;
bool cancel_safe; bool cancel_safe;
void set_cancel( bool force ); void set_cancel( bool force );
void copy_block();
public: public:
bool set_progress_info(); bool set_progress_info();
copy_blocks( const Glib::ustring & in_src_device, CopyBlocks( const Glib::ustring & in_src_device,
const Glib::ustring & in_dst_device, const Glib::ustring & in_dst_device,
Sector src_start, Sector src_start,
Sector dst_start, Sector dst_start,
Byte_Value in_length, Byte_Value in_length,
Byte_Value in_blocksize, Byte_Value in_blocksize,
OperationDetail & in_operationdetail, OperationDetail & in_operationdetail,
Byte_Value & in_total_done, Byte_Value & in_total_done,
Byte_Value in_total_length, Byte_Value in_total_length,
bool cancel_safe ); bool cancel_safe );
bool copy(); bool copy();
void copy_block();
}; };
} // namespace GParted } // namespace GParted
#endif /* GPARTED_COPY_BLOCKS_H */ #endif /* GPARTED_COPYBLOCKS_H */

View File

@ -2,7 +2,7 @@ gparted_includedir = $(pkgincludedir)
EXTRA_DIST = \ EXTRA_DIST = \
BlockSpecial.h \ BlockSpecial.h \
Copy_Blocks.h \ CopyBlocks.h \
DMRaid.h \ DMRaid.h \
Device.h \ Device.h \
DialogFeatures.h \ DialogFeatures.h \

View File

@ -4,7 +4,7 @@ gparted.appdata.xml.in
gparted.desktop.in.in gparted.desktop.in.in
include/Utils.h include/Utils.h
src/BlockSpecial.cc src/BlockSpecial.cc
src/Copy_Blocks.cc src/CopyBlocks.cc
src/Dialog_Base_Partition.cc src/Dialog_Base_Partition.cc
src/Dialog_Disklabel.cc src/Dialog_Disklabel.cc
src/Dialog_FileSystem_Label.cc src/Dialog_FileSystem_Label.cc

View File

@ -16,7 +16,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "../include/Copy_Blocks.h" #include "../include/CopyBlocks.h"
#include "../include/OperationDetail.h" #include "../include/OperationDetail.h"
#include "../include/ProgressBar.h" #include "../include/ProgressBar.h"
#include "../include/Utils.h" #include "../include/Utils.h"
@ -27,22 +27,22 @@
namespace GParted { namespace GParted {
void copy_blocks::set_cancel( bool force ) void CopyBlocks::set_cancel( bool force )
{ {
if ( force || cancel_safe ) if ( force || cancel_safe )
cancel = true; cancel = true;
} }
copy_blocks::copy_blocks( const Glib::ustring & in_src_device, CopyBlocks::CopyBlocks( const Glib::ustring & in_src_device,
const Glib::ustring & in_dst_device, const Glib::ustring & in_dst_device,
Sector src_start, Sector src_start,
Sector dst_start, Sector dst_start,
Byte_Value in_length, Byte_Value in_length,
Byte_Value in_blocksize, Byte_Value in_blocksize,
OperationDetail & in_operationdetail, OperationDetail & in_operationdetail,
Byte_Value & in_total_done, Byte_Value & in_total_done,
Byte_Value in_total_length, Byte_Value in_total_length,
bool in_cancel_safe) : bool in_cancel_safe) :
src_device( in_src_device ), src_device( in_src_device ),
dst_device ( in_dst_device ), dst_device ( in_dst_device ),
length ( in_length ), length ( in_length ),
@ -56,12 +56,12 @@ copy_blocks::copy_blocks( const Glib::ustring & in_src_device,
cancel_safe ( in_cancel_safe ) cancel_safe ( in_cancel_safe )
{ {
operationdetail.signal_cancel.connect( operationdetail.signal_cancel.connect(
sigc::mem_fun(*this, &copy_blocks::set_cancel)); sigc::mem_fun(*this, &CopyBlocks::set_cancel));
if (operationdetail.cancelflag) if (operationdetail.cancelflag)
set_cancel( operationdetail.cancelflag == 2 ); set_cancel( operationdetail.cancelflag == 2 );
} }
bool copy_blocks::set_progress_info() bool CopyBlocks::set_progress_info()
{ {
Byte_Value done = llabs(this->done); Byte_Value done = llabs(this->done);
operationdetail.run_progressbar( (double)(total_done+done), (double)total_length, PROGRESSBAR_TEXT_COPY_BYTES ); 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; return false;
} }
static bool mainquit(copy_blocks *cb) static bool mainquit( CopyBlocks *cb )
{ {
while ( Gtk::Main::events_pending() ) while ( Gtk::Main::events_pending() )
Gtk::Main::iteration(); Gtk::Main::iteration();
@ -84,11 +84,11 @@ static bool mainquit(copy_blocks *cb)
static gboolean _set_progress_info( gpointer data ) static gboolean _set_progress_info( gpointer data )
{ {
copy_blocks *cb = (copy_blocks *)data; CopyBlocks *cb = (CopyBlocks *)data;
return cb->set_progress_info(); return cb->set_progress_info();
} }
void copy_blocks::copy_thread() void CopyBlocks::copy_thread()
{ {
if ( ped_device_open( lp_device_src ) && if ( ped_device_open( lp_device_src ) &&
(lp_device_src == lp_device_dst || ped_device_open( lp_device_dst ) ) ) (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 ); g_idle_add( (GSourceFunc)mainquit, this );
} }
bool copy_blocks::copy() bool CopyBlocks::copy()
{ {
if ( blocksize > length ) if ( blocksize > length )
blocksize = length; blocksize = length;
@ -167,7 +167,7 @@ bool copy_blocks::copy()
buf = static_cast<char *>( malloc( llabs( blocksize ) ) ); buf = static_cast<char *>( malloc( llabs( blocksize ) ) );
if ( buf ) if ( buf )
{ {
Glib::Thread::create( sigc::mem_fun( *this, &copy_blocks::copy_thread ), Glib::Thread::create( sigc::mem_fun( *this, &CopyBlocks::copy_thread ),
false ); false );
Gtk::Main::run(); Gtk::Main::run();
@ -198,7 +198,7 @@ bool copy_blocks::copy()
return success; 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_src = lp_device_src ->sector_size;
Byte_Value sector_size_dst = lp_device_dst ->sector_size; Byte_Value sector_size_dst = lp_device_dst ->sector_size;

View File

@ -48,7 +48,7 @@
#include "../include/hfsplus.h" #include "../include/hfsplus.h"
#include "../include/reiser4.h" #include "../include/reiser4.h"
#include "../include/ufs.h" #include "../include/ufs.h"
#include "../include/Copy_Blocks.h" #include "../include/CopyBlocks.h"
#include <cerrno> #include <cerrno>
#include <cstring> #include <cstring>
@ -2997,16 +2997,16 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device,
benchmark_blocksize <= N ) benchmark_blocksize <= N )
{ {
timer .reset() ; timer .reset() ;
succes = copy_blocks( src_device, succes = CopyBlocks( src_device,
dst_device, dst_device,
offset_read + (done / src_sector_size), offset_read + (done / src_sector_size),
offset_write + (done / dst_sector_size), offset_write + (done / dst_sector_size),
N, N,
benchmark_blocksize, benchmark_blocksize,
operationdetail .get_last_child(), operationdetail .get_last_child(),
total_done, total_done,
src_length, src_length,
cancel_safe ).copy(); cancel_safe ).copy();
timer.stop() ; timer.stop() ;
operationdetail .get_last_child() .get_last_child() .add_child( OperationDetail( 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 ) ) ; STATUS_NONE ) ) ;
if ( succes && llabs( done ) < src_length ) if ( succes && llabs( done ) < src_length )
succes = copy_blocks( src_device, succes = CopyBlocks( src_device,
dst_device, dst_device,
src_start + ((done > 0 ? done : 0) / src_sector_size), src_start + ((done > 0 ? done : 0) / src_sector_size),
dst_start + ((done > 0 ? done : 0) / dst_sector_size), dst_start + ((done > 0 ? done : 0) / dst_sector_size),
src_length - llabs( done ), src_length - llabs( done ),
optimal_blocksize, optimal_blocksize,
operationdetail, operationdetail,
total_done, total_done,
src_length, src_length,
cancel_safe ).copy(); cancel_safe ).copy();
operationdetail .add_child( OperationDetail( operationdetail .add_child( OperationDetail(
String::ucompose( /*TO TRANSLATORS: looks like 1.00 MiB (1048576 B) copied */ String::ucompose( /*TO TRANSLATORS: looks like 1.00 MiB (1048576 B) copied */

View File

@ -13,7 +13,7 @@ sbin_PROGRAMS = gpartedbin
gpartedbin_SOURCES = \ gpartedbin_SOURCES = \
BlockSpecial.cc \ BlockSpecial.cc \
Copy_Blocks.cc \ CopyBlocks.cc \
DMRaid.cc \ DMRaid.cc \
Device.cc \ Device.cc \
DialogFeatures.cc \ DialogFeatures.cc \