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 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 <goossens.rogier@gmail.com>
* 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/>.
*/
#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 */

View file

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

View file

@ -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

View file

@ -16,7 +16,7 @@
* 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/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, &copy_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<char *>( malloc( llabs( blocksize ) ) );
if ( buf )
{
Glib::Thread::create( sigc::mem_fun( *this, &copy_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;

View file

@ -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 <cerrno>
#include <cstring>
@ -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 */

View file

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