use new copy_block() in copy_filesystem()

* src/GParted_Core.cc: use new copy_block() in copy_filesystem()
This commit is contained in:
Bart Hakvoort 2006-06-18 19:56:48 +00:00
parent b223e829ab
commit a150c58852
2 changed files with 22 additions and 28 deletions

View File

@ -1,3 +1,7 @@
2006-06-18 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/GParted_Core.cc: use new copy_block() in copy_filesystem()
2006-06-18 Bart Hakvoort <hakvoort@cvs.gnome.org> 2006-06-18 Bart Hakvoort <hakvoort@cvs.gnome.org>
* include/GParted_Core.h, * include/GParted_Core.h,

View File

@ -1134,7 +1134,7 @@ bool GParted_Core::move_filesystem( const Partition & partition_old,
close_disk() ; close_disk() ;
//do the move.. //do the move..
Sector blocksize = 32 ; Sector blocksize = 32 ;//FIXME: write an algorithm to determine the optimal blocksize
Glib::ustring error_message ; Glib::ustring error_message ;
if ( succes && ped_device_open( lp_device ) ) if ( succes && ped_device_open( lp_device ) )
@ -1191,7 +1191,8 @@ bool GParted_Core::move_filesystem( const Partition & partition_old,
} }
} }
else //move to the right.. else //move to the right..
{ {//FIXME: why is this so much slower than moving to the left or a simple copy? most likely there's
//an error in the algorithm
Sector t = blocksize ; Sector t = blocksize ;
for ( ; t < partition_old .get_length() - blocksize ; t+=blocksize ) for ( ; t < partition_old .get_length() - blocksize ; t+=blocksize )
{ {
@ -1619,7 +1620,6 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
OperationDetails::NONE ) ) ; OperationDetails::NONE ) ) ;
bool succes = false ; bool succes = false ;
char buf[block_size * 512] ;
PedDevice *lp_device_src, *lp_device_dest ; PedDevice *lp_device_src, *lp_device_dest ;
//FIXME: adapt open_device() so we don't have to call ped_device_get() here //FIXME: adapt open_device() so we don't have to call ped_device_get() here
//(same goes for close_device() and ped_device_destroy() //(same goes for close_device() and ped_device_destroy()
@ -1642,21 +1642,15 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
Sector t = 0 ; Sector t = 0 ;
for ( ; t < partition_src .get_length() - block_size ; t+=block_size ) for ( ; t < partition_src .get_length() - block_size ; t+=block_size )
{ {
if ( ! ped_device_read( lp_device_src, buf, partition_src .sector_start + t, block_size ) ) if ( ! copy_block( lp_device_src,
{ lp_device_dest,
error_message = "<i>" + String::ucompose( _("Error while reading block at sector %1"), partition_src .sector_start + t,
partition_src .sector_start + t ) + "</i>" ; partition_dest .sector_start + t,
block_size,
error_message ) )
break ; break ;
}
if ( ! ped_device_write( lp_device_dest, buf, partition_dest .sector_start + t, block_size ) )
{
error_message = "<i>" + String::ucompose( _("Error while writing block at sector %1"),
partition_src .sector_start + t ) + "</i>" ;
break ;
}
if ( t % ( block_size * 100 ) == 0 ) if ( t % ( block_size * 100 ) == 0 )
{ {
@ -1675,17 +1669,13 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
//copy the last couple of sectors.. //copy the last couple of sectors..
Sector last_sectors = partition_src .get_length() - t ;//FIXME: most likely this is incorrect, look at move_filesystem to see how they do it. Sector last_sectors = partition_src .get_length() - t ;//FIXME: most likely this is incorrect, look at move_filesystem to see how they do it.
if ( ped_device_read( lp_device_src, buf, partition_src .sector_start + t, last_sectors ) ) if ( copy_block( lp_device_src,
{ lp_device_dest,
if ( ped_device_write( lp_device_dest, buf, partition_dest .sector_start + t , last_sectors ) ) partition_src .sector_start + t,
partition_dest .sector_start + t,
last_sectors,
error_message ) )
t += last_sectors ; t += last_sectors ;
else
error_message = "<i>" + String::ucompose( _("Error while writing block at sector %1"),
partition_src .sector_start + t ) + "</i>" ;
}
else
error_message = "<i>" + String::ucompose( _("Error while reading block at sector %1"),
partition_src .sector_start + t ) + "</i>" ;
//final description //final description
operation_details .back() .sub_details .back() .description = operation_details .back() .sub_details .back() .description =