made blocksize settable by the user.
* include/Dialog_Partition_Copy.h, include/GParted_Core.h, include/OperationCopy.h, include/Win_GParted.h, src/Dialog_Partition_Copy.cc, src/GParted_Core.cc, src/OperationCopy.cc, src/Win_GParted.cc: made blocksize settable by the user.
This commit is contained in:
parent
7b56107ce9
commit
7ff0609962
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2006-05-27 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Dialog_Partition_Copy.h,
|
||||
include/GParted_Core.h,
|
||||
include/OperationCopy.h,
|
||||
include/Win_GParted.h,
|
||||
src/Dialog_Partition_Copy.cc,
|
||||
src/GParted_Core.cc,
|
||||
src/OperationCopy.cc,
|
||||
src/Win_GParted.cc: made blocksize settable by the user.
|
||||
|
||||
2006-05-26 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* src/GParted_Core.cc: fixed typo (#343015)
|
||||
|
|
|
@ -28,10 +28,13 @@ class Dialog_Partition_Copy : public Dialog_Base_Partition
|
|||
public:
|
||||
Dialog_Partition_Copy( const FS & fs, Sector cylinder_size ) ;
|
||||
void Set_Data( const Partition & selected_partition, const Partition & copied_partition );
|
||||
|
||||
Partition Get_New_Partition() ;
|
||||
Sector get_block_size() ;
|
||||
|
||||
private:
|
||||
|
||||
Gtk::HBox hbox_block_size ;
|
||||
Gtk::SpinButton spinbutton_block_size ;
|
||||
};
|
||||
|
||||
}//GParted
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
bool copy( const Partition & partition_src,
|
||||
Partition & partition_dest,
|
||||
Sector min_size,
|
||||
Sector block_size,
|
||||
std::vector<OperationDetails> & operation_details ) ;
|
||||
|
||||
bool Set_Disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ;
|
||||
|
@ -93,7 +94,8 @@ private:
|
|||
|
||||
bool copy_filesystem( const Partition & partition_src,
|
||||
const Partition & partition_dest,
|
||||
std::vector<OperationDetails> & operation_details ) ;
|
||||
std::vector<OperationDetails> & operation_details,
|
||||
Sector block_size ) ;
|
||||
|
||||
void set_proper_filesystem( const FILESYSTEM & filesystem ) ;
|
||||
bool set_partition_type( const Partition & partition,
|
||||
|
|
|
@ -29,11 +29,13 @@ public:
|
|||
OperationCopy( const Device & device,
|
||||
const Partition & partition_orig,
|
||||
const Partition & partition_new,
|
||||
const Partition & partition_copied) ;
|
||||
const Partition & partition_copied,
|
||||
Sector block_size ) ;
|
||||
|
||||
void apply_to_visual( std::vector<Partition> & partitions ) ;
|
||||
|
||||
Partition partition_copied ;
|
||||
Sector block_size ;
|
||||
|
||||
private:
|
||||
void create_description() ;
|
||||
|
|
|
@ -63,7 +63,10 @@ private:
|
|||
//Fill txtview_device_info_buffer with some information about the selected device
|
||||
void Fill_Label_Device_Info( bool clear = false );
|
||||
|
||||
void Add_Operation( OperationType operationtype, const Partition & new_partition, int index = -1 ) ;
|
||||
void Add_Operation( OperationType operationtype,
|
||||
const Partition & new_partition,
|
||||
Sector block_size = -1,
|
||||
int index = -1 ) ;
|
||||
void Refresh_Visual();
|
||||
bool Quit_Check_Operations();
|
||||
void set_valid_operations() ;
|
||||
|
|
|
@ -88,12 +88,26 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
|||
Utils::round( Utils::sector_to_unit( fs .MIN, GParted::UNIT_MIB ) ),
|
||||
Utils::round( Utils::sector_to_unit( fs .MAX, GParted::UNIT_MIB ) ) ) ;
|
||||
|
||||
|
||||
//allow the user to set the size of the blocks which will be copied at once
|
||||
hbox_block_size .set_spacing( 10 ) ;
|
||||
this ->get_vbox() ->pack_start( hbox_block_size ) ;
|
||||
hbox_block_size .pack_start( * Utils::mk_label( _("Blocksize (sectors):") ), Gtk::PACK_SHRINK ) ;
|
||||
|
||||
spinbutton_block_size .set_numeric( true ) ;
|
||||
spinbutton_block_size .set_increments( 1, 10 ) ;
|
||||
spinbutton_block_size .set_range( 1, MEBIBYTE ) ;
|
||||
spinbutton_block_size .set_value( 32 ) ;
|
||||
hbox_block_size .pack_start( spinbutton_block_size, Gtk::PACK_SHRINK ) ;
|
||||
|
||||
//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
|
||||
this ->selected_partition = copied_partition ;
|
||||
this ->selected_partition .device_path = selected_partition .device_path ;
|
||||
this ->selected_partition .inside_extended = selected_partition .inside_extended ;
|
||||
this ->selected_partition .type =
|
||||
selected_partition .inside_extended ? GParted::TYPE_LOGICAL : GParted::TYPE_PRIMARY ;
|
||||
|
||||
this ->show_all_children() ;
|
||||
}
|
||||
|
||||
Partition Dialog_Partition_Copy::Get_New_Partition()
|
||||
|
@ -106,5 +120,9 @@ Partition Dialog_Partition_Copy::Get_New_Partition()
|
|||
|
||||
return selected_partition ;
|
||||
}
|
||||
Sector Dialog_Partition_Copy::get_block_size()
|
||||
{
|
||||
return spinbutton_block_size .get_value_as_int() ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -654,6 +654,7 @@ bool GParted_Core::apply_operation_to_disk( Operation * operation )
|
|||
return copy( static_cast<OperationCopy*>( operation ) ->partition_copied,
|
||||
operation ->partition_new,
|
||||
static_cast<OperationCopy*>( operation ) ->partition_copied .get_length(),
|
||||
static_cast<OperationCopy*>( operation ) ->block_size,
|
||||
operation ->operation_details .sub_details ) ;
|
||||
}
|
||||
|
||||
|
@ -785,6 +786,7 @@ bool GParted_Core::resize( const Device & device,
|
|||
bool GParted_Core::copy( const Partition & partition_src,
|
||||
Partition & partition_dest,
|
||||
Sector min_size,
|
||||
Sector block_size,
|
||||
std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
set_proper_filesystem( partition_dest .filesystem ) ;
|
||||
|
@ -806,7 +808,8 @@ bool GParted_Core::copy( const Partition & partition_src,
|
|||
case GParted::FS::GPARTED :
|
||||
succes = copy_filesystem( partition_src,
|
||||
partition_dest,
|
||||
operation_details ) ;
|
||||
operation_details,
|
||||
block_size ) ;
|
||||
break ;
|
||||
|
||||
case GParted::FS::LIBPARTED :
|
||||
|
@ -1258,11 +1261,17 @@ bool GParted_Core::resize_normal_using_libparted( const Partition & partition_ol
|
|||
|
||||
bool GParted_Core::copy_filesystem( const Partition & partition_src,
|
||||
const Partition & partition_dest,
|
||||
std::vector<OperationDetails> & operation_details )
|
||||
{//FIXME: try to increase speed by copying more sectors at once, this should probably become a userspace setting
|
||||
bool succes = false ;
|
||||
std::vector<OperationDetails> & operation_details,
|
||||
Sector block_size )
|
||||
{
|
||||
operation_details .back() .sub_details .push_back( OperationDetails(
|
||||
"<i>" + String::ucompose( _("Use a blocksize of %1 (%2 sectors)"),
|
||||
Utils::format_size( block_size ),
|
||||
block_size ) + "</i>",
|
||||
OperationDetails::NONE ) ) ;
|
||||
|
||||
char buf[1024] ;
|
||||
bool succes = false ;
|
||||
char buf[block_size * 512] ;
|
||||
PedDevice *lp_device_src, *lp_device_dest ;
|
||||
//FIXME: adapt open_device() so we don't have to call ped_device_get() here
|
||||
//(same goes for close_device() and ped_device_destroy()
|
||||
|
@ -1283,25 +1292,25 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
|
|||
|
||||
Glib::ustring error_message ;
|
||||
Sector t = 0 ;
|
||||
for ( ; t < partition_src .get_length() ; t++ )
|
||||
for ( ; t < partition_src .get_length() - block_size ; t+=block_size )
|
||||
{
|
||||
if ( ! ped_device_read( lp_device_src, buf, partition_src .sector_start + t, 1 ) )
|
||||
if ( ! ped_device_read( lp_device_src, buf, partition_src .sector_start + t, block_size ) )
|
||||
{
|
||||
error_message = "<i>" + String::ucompose( _("Error while reading sector %1"),
|
||||
error_message = "<i>" + String::ucompose( _("Error while reading block at sector %1"),
|
||||
partition_src .sector_start + t ) + "</i>" ;
|
||||
|
||||
break ;
|
||||
}
|
||||
|
||||
if ( ! ped_device_write( lp_device_dest, buf, partition_dest .sector_start + t, 1 ) )
|
||||
if ( ! ped_device_write( lp_device_dest, buf, partition_dest .sector_start + t, block_size ) )
|
||||
{
|
||||
error_message = "<i>" + String::ucompose( _("Error while writing sector %1"),
|
||||
error_message = "<i>" + String::ucompose( _("Error while writing block at sector %1"),
|
||||
partition_src .sector_start + t ) + "</i>" ;
|
||||
|
||||
break ;
|
||||
}
|
||||
|
||||
if ( t % MEBIBYTE == 0 )
|
||||
if ( t % ( block_size * 100 ) == 0 )
|
||||
{
|
||||
operation_details .back() .sub_details .back() .progress_text =
|
||||
String::ucompose( _("%1 of %2 copied"),
|
||||
|
@ -1316,6 +1325,20 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
|
|||
}
|
||||
}
|
||||
|
||||
//copy the last couple of sectors..
|
||||
Sector last_sectors = partition_src .get_length() - t ;
|
||||
if ( ped_device_read( lp_device_src, buf, partition_src .sector_start + t, last_sectors ) )
|
||||
{
|
||||
if ( ped_device_write( lp_device_dest, buf, partition_dest .sector_start + 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
|
||||
operation_details .back() .sub_details .back() .description =
|
||||
"<i>" +
|
||||
|
|
|
@ -23,7 +23,8 @@ namespace GParted
|
|||
OperationCopy::OperationCopy( const Device & device,
|
||||
const Partition & partition_orig,
|
||||
const Partition & partition_new,
|
||||
const Partition & partition_copied )
|
||||
const Partition & partition_copied,
|
||||
Sector block_size )
|
||||
{
|
||||
type = GParted::COPY ;
|
||||
|
||||
|
@ -31,6 +32,7 @@ OperationCopy::OperationCopy( const Device & device,
|
|||
this ->partition_original = partition_orig ;
|
||||
this ->partition_new = partition_new ;
|
||||
this ->partition_copied = partition_copied ;
|
||||
this ->block_size = block_size ;
|
||||
|
||||
create_description() ;
|
||||
|
||||
|
@ -89,7 +91,6 @@ void OperationCopy::create_description()
|
|||
partition_copied .get_path(),
|
||||
partition_original .get_path() ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -573,7 +573,13 @@ bool Win_GParted::on_delete_event( GdkEventAny *event )
|
|||
return ! Quit_Check_Operations();
|
||||
}
|
||||
|
||||
void Win_GParted::Add_Operation( OperationType operationtype, const Partition & new_partition, int index )
|
||||
//FIXME: i guess it's better if we just create the operations in the activate_* functions instead
|
||||
//of doing it here. now we're adding more and more functionality (e.g. blocksize) to the operations
|
||||
//the current approach doesn't suffice anymore.
|
||||
void Win_GParted::Add_Operation( OperationType operationtype,
|
||||
const Partition & new_partition,
|
||||
Sector block_size,
|
||||
int index )
|
||||
{
|
||||
Operation * operation ;
|
||||
switch ( operationtype )
|
||||
|
@ -604,7 +610,8 @@ void Win_GParted::Add_Operation( OperationType operationtype, const Partition &
|
|||
operation = new OperationCopy( devices[ current_device ],
|
||||
selected_partition,
|
||||
new_partition,
|
||||
copied_partition ) ;
|
||||
copied_partition,
|
||||
block_size ) ;
|
||||
operation ->icon = render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU );
|
||||
break;
|
||||
}
|
||||
|
@ -1269,7 +1276,7 @@ void Win_GParted::activate_paste()
|
|||
if ( dialog .run() == Gtk::RESPONSE_OK )
|
||||
{
|
||||
dialog .hide() ;
|
||||
Add_Operation( GParted::COPY, dialog .Get_New_Partition() );
|
||||
Add_Operation( GParted::COPY, dialog .Get_New_Partition(), dialog .get_block_size() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1282,7 +1289,10 @@ void Win_GParted::activate_paste()
|
|||
partition_new .error .clear() ;
|
||||
partition_new .status = GParted::STAT_COPY ;
|
||||
|
||||
Add_Operation( GParted::COPY, partition_new ) ;
|
||||
//FIXME: in this case there's no window presented to the user, so he cannot choose the blocksize
|
||||
//i guess this means we have to present a window with the choice (maybe the copydialog, with everything
|
||||
//except the blocksize disabled?
|
||||
Add_Operation( GParted::COPY, partition_new, 32 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1469,7 +1479,7 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
|
|||
//(NOTE: in this case we set status to STAT_NEW)
|
||||
part_temp .status = STAT_NEW ;
|
||||
|
||||
Add_Operation( GParted::CREATE, part_temp, t );
|
||||
Add_Operation( GParted::CREATE, part_temp, -1, t );
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue