changed progressfeedbackhandling a bit. Because this affected

* changed progressfeedbackhandling a bit. Because this affected
  OperationDetail i had to make changes in almost every file.
This commit is contained in:
Bart Hakvoort 2006-08-20 09:33:54 +00:00
parent f61b537c0d
commit 889ab1232f
35 changed files with 647 additions and 608 deletions

View file

@ -1,3 +1,8 @@
2006-08-20 Bart Hakvoort <hakvoort@cvs.gnome.org>
* changed progressfeedbackhandling a bit. Because this affected
OperationDetail i had to make changes in almost every file.
2006-08-16 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/GParted_Core.cc: added 'time remaining' to progressfeedback.

View file

@ -43,7 +43,8 @@ public:
sigc::signal< bool, Operation * > signal_apply_operation ;
private:
void update_operation_details( const Gtk::TreeRow & treerow, const OperationDetail & operation_detail ) ;
void on_signal_update( const OperationDetail & operationdetail ) ;
void dispatcher_on_update_gui_elements() ;
void on_signal_show() ;
void on_expander_changed() ;
void on_cell_data_description( Gtk::CellRenderer * renderer, const Gtk::TreeModel::iterator & iter) ;
@ -89,11 +90,15 @@ private:
treeview_operations_Columns treeview_operations_columns;
std::vector<Operation *> operations ;
OperationDetail operationdetail ;
bool running, succes, cancel, pulse ;
pthread_t pthread ;
double fraction ;
unsigned int t ;
Glib::ustring str_temp ;
Glib::Dispatcher dispatcher_update_gui_elements ;
Glib::ustring label_current_sub_text ;
};
}//GParted

View file

@ -34,18 +34,18 @@ public:
virtual ~FileSystem() {}
virtual FS get_filesystem_support() = 0 ;
virtual void Set_Used_Sectors( Partition & partition ) = 0 ;
virtual bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) = 0 ;
virtual bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
virtual void set_used_sectors( Partition & partition ) = 0 ;
virtual bool create( const Partition & new_partition, OperationDetail & operationdetail ) = 0 ;
virtual bool resize( const Partition & partition_new,
OperationDetail & operationdetail,
bool fill_partition = false ) = 0 ;
virtual bool Copy( const Glib::ustring & src_part_path,
virtual bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) = 0 ;
virtual bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) = 0 ;
OperationDetail & operationdetail ) = 0 ;
virtual bool check_repair( const Partition & partition, OperationDetail & operationdetail ) = 0 ;
protected:
int execute_command( const Glib::ustring & command, std::vector<OperationDetail> & operation_details ) ;
int execute_command( const Glib::ustring & command, OperationDetail & operationdetail ) ;
//those are used in several places..
Glib::ustring output, error ;

View file

@ -71,60 +71,54 @@ private:
void set_flags( Partition & partition ) ;
//operationstuff...
bool create( const Device & device,
Partition & new_partition,
std::vector<OperationDetail> & operation_details ) ;
bool create_partition( Partition & new_partition,
std::vector<OperationDetail> & operation_details,
Sector min_size = 0 ) ;
bool create_filesystem( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
bool create( const Device & device, Partition & new_partition, OperationDetail & operationdetail ) ;
bool create_partition( Partition & new_partition, OperationDetail & operationdetail, Sector min_size = 0 ) ;
bool create_filesystem( const Partition & partition, OperationDetail & operationdetail ) ;
bool format( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
bool format( const Partition & partition, OperationDetail & operationdetail ) ;
bool Delete( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
bool Delete( const Partition & partition, OperationDetail & operationdetail ) ;
bool resize_move( const Device & device,
const Partition & partition_old,
Partition & partition_new,
std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool move( const Device & device,
const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool move_filesystem( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool move_filesystem_using_gparted( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool resize_move_filesystem_using_libparted( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_detail ) ;
OperationDetail & operationdetail ) ;
bool resize_move_partition( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool resize_filesystem( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
OperationDetail & operationdetail,
bool fill_partition = false ) ;
bool maximize_filesystem( const Partition & partition,
std::vector<OperationDetail> & operation_details ) ;
bool maximize_filesystem( const Partition & partition, OperationDetail & operationdetail ) ;
bool copy( const Partition & partition_src,
Partition & partition_dest,
Sector min_size,
std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool copy_filesystem( const Partition & partition_src,
const Partition & partition_dest,
std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair_filesystem( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
bool check_repair_filesystem( const Partition & partition, OperationDetail & operationdetail ) ;
bool set_partition_type( const Partition & partition,
std::vector<OperationDetail> & operation_details ) ;
bool set_partition_type( const Partition & partition, OperationDetail & operationdetail ) ;
void set_progress_info( Sector total, Sector done, std::time_t time_start, OperationDetail & operationdetail ) ;
@ -138,7 +132,7 @@ private:
CopyType copytype,
Sector & optimal_blocksize,
Sector & offset,
std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool copy_blocks( const Glib::ustring & src_device,
const Glib::ustring & dst_device,
@ -146,9 +140,8 @@ private:
Sector dst_start,
Sector blocksize,
Sector sectors,
std::vector<OperationDetail> & operation_details,
CopyType copytype,
bool show_progress = true ) ;
OperationDetail & operationdetail,
CopyType copytype ) ;
bool copy_block( PedDevice * lp_device_src,
PedDevice * lp_device_dst,
@ -158,7 +151,7 @@ private:
Glib::ustring & error_message ) ;
bool calculate_exact_geom( const Partition & partition_old,
Partition & partition_new,
std::vector<OperationDetail> & operation_details,
OperationDetail & operationdetail,
Sector min_size = -1 ) ;
bool set_proper_filesystem( const FILESYSTEM & filesystem ) ;
bool wait_for_node( const Glib::ustring & node ) ;

View file

@ -51,15 +51,30 @@ public:
Font font = FONT_NORMAL ) ;
void set_description( const Glib::ustring & description, Font font = FONT_NORMAL ) ;
Glib::ustring get_description() const ;
void set_status( OperationDetailStatus status ) ;
OperationDetailStatus get_status() const ;
void set_treepath( const Glib::ustring & treepath ) ;
Glib::ustring get_treepath() const ;
void add_child( const OperationDetail & operationdetail ) ;
std::vector<OperationDetail> & get_childs() ;
const std::vector<OperationDetail> & get_childs() const ;
OperationDetail & get_last_child() ;
OperationDetailStatus status ;
double fraction ;
Glib::ustring progress_text ;
std::vector<OperationDetail> sub_details ;
sigc::signal< void, const OperationDetail & > signal_update ;
private:
void on_update( const OperationDetail & operationdetail ) ;
Glib::ustring description ;
OperationDetailStatus status ;
Glib::ustring treepath ;
std::vector<OperationDetail> sub_details ;
};
} //GParted

View file

@ -28,15 +28,13 @@ class ext2 : public FileSystem
{
public:
FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};
} //GParted

View file

@ -28,15 +28,13 @@ class ext3 : public FileSystem
{
public:
FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};

View file

@ -28,15 +28,13 @@ class fat16 : public FileSystem
{
public:
FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};
} //GParted

View file

@ -28,15 +28,13 @@ class fat32 : public FileSystem
{
public:
FS get_filesystem_support();
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};
} //GParted

View file

@ -28,15 +28,13 @@ class hfs : public FileSystem
{
public:
FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};
} //GParted

View file

@ -28,15 +28,13 @@ class hfsplus : public FileSystem
{
public:
FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};
} //GParted

View file

@ -28,15 +28,13 @@ class jfs : public FileSystem
{
public:
FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};
} //GParted

View file

@ -28,15 +28,13 @@ class linux_swap : public FileSystem
{
public:
FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};
} //GParted

View file

@ -28,15 +28,13 @@ class ntfs : public FileSystem
{
public:
FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};
} //GParted

View file

@ -28,15 +28,13 @@ class reiser4 : public FileSystem
{
public:
FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};
} //GParted

View file

@ -28,15 +28,13 @@ class reiserfs : public FileSystem
{
public:
FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};
} //GParted

View file

@ -28,15 +28,13 @@ class ufs : public FileSystem
{
public:
FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};
} //GParted

View file

@ -28,15 +28,13 @@ class xfs : public FileSystem
{
public:
FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details ) ;
bool Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path,
void set_used_sectors( Partition & partition ) ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
bool copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details ) ;
OperationDetail & operationdetail ) ;
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
};
} //GParted

View file

@ -35,6 +35,9 @@ Dialog_Progress::Dialog_Progress( const std::vector<Operation *> & operations )
cancel = false ;
fraction = 1.00 / operations .size() ;
dispatcher_update_gui_elements .connect(
sigc::mem_fun( this, &Dialog_Progress::dispatcher_on_update_gui_elements ) ) ;
Glib::ustring str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += _("Applying pending operations") ;
@ -54,7 +57,8 @@ Dialog_Progress::Dialog_Progress( const std::vector<Operation *> & operations )
label_current_sub .set_alignment( Gtk::ALIGN_LEFT );
this ->get_vbox() ->pack_start( label_current_sub, Gtk::PACK_SHRINK );
this ->get_vbox() ->pack_start( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("Completed Operations:") ) + "</b>" ), Gtk::PACK_SHRINK );
this ->get_vbox() ->pack_start( * Utils::mk_label( "<b>" + Glib::ustring( _("Completed Operations:") ) + "</b>" ),
Gtk::PACK_SHRINK );
this ->get_vbox() ->pack_start( progressbar_all, Gtk::PACK_SHRINK );
//create some icons here, instead of recreating them every time
@ -77,6 +81,7 @@ Dialog_Progress::Dialog_Progress( const std::vector<Operation *> & operations )
for ( unsigned int t = 0 ; t < operations .size() ; t++ )
{
this ->operations[ t ] ->operation_detail .set_description( operations[ t ] ->description, FONT_BOLD ) ;
this ->operations[ t ] ->operation_detail .set_treepath( Utils::num_to_str( t ) ) ;
treerow = *( treestore_operations ->append() );
treerow[ treeview_operations_columns .operation_icon ] = operations[ t ] ->icon ;
@ -94,7 +99,7 @@ Dialog_Progress::Dialog_Progress( const std::vector<Operation *> & operations )
scrolledwindow .set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ) ;
scrolledwindow .add( treeview_operations ) ;
expander_details .set_label( "<b>" + static_cast<Glib::ustring>( _("Details") ) + "</b>" ) ;
expander_details .set_label( "<b>" + Glib::ustring( _("Details") ) + "</b>" ) ;
expander_details .set_use_markup( true ) ;
expander_details .property_expanded() .signal_changed() .connect(
sigc::mem_fun(*this, &Dialog_Progress::on_expander_changed) );
@ -109,81 +114,85 @@ Dialog_Progress::Dialog_Progress( const std::vector<Operation *> & operations )
this ->show_all_children() ;
}
void Dialog_Progress::update_operation_details( const Gtk::TreeRow & treerow,
const OperationDetail & operation_detail )
void Dialog_Progress::on_signal_update( const OperationDetail & operationdetail )
{
//append new rows (if any)
for ( unsigned int t = treerow .children() .size() ; t < operation_detail .sub_details .size() ; t++ )
{
Gtk::TreeRow treerow_child = *( treestore_operations ->append( treerow .children() ) ) ;
//FIXME, consider adding a textwidget to the tree for storing the text. simply storing text directly in the tree
//doesn't work with HUGE amounts of text.
treerow_child[ treeview_operations_columns .operation_description ] =
operation_detail .sub_details[ t ] .get_description() ;
treerow_child[ treeview_operations_columns .hidden_status ] = STATUS_NONE ;
}
//check status and update if necessary
if ( operation_detail .status != treerow[ treeview_operations_columns .hidden_status ] )
{
treerow[ treeview_operations_columns .hidden_status ] = operation_detail .status ;
Gtk::TreeModel::iterator iter = treestore_operations ->get_iter( operationdetail .get_treepath() ) ;
switch ( operation_detail .status )
if ( iter )
{
Gtk::TreeRow treerow = *iter ;
treerow[ treeview_operations_columns .operation_description ] = operationdetail .get_description() ;
switch ( operationdetail .get_status() )
{
case STATUS_EXECUTE:
treerow[ treeview_operations_columns .status_icon ] = icon_execute ;
break ;
case STATUS_SUCCES:
treerow[ treeview_operations_columns .status_icon ] = icon_succes ;
break ;
case STATUS_ERROR:
treerow[ treeview_operations_columns .status_icon ] = icon_error ;
break ;
case STATUS_INFO:
treerow[ treeview_operations_columns .status_icon ] = icon_info ;
break ;
case STATUS_N_A:
treerow[ treeview_operations_columns .status_icon ] = icon_n_a ;
break ;
default :
treerow[ treeview_operations_columns .hidden_status ] = STATUS_NONE ;
case STATUS_NONE:
static_cast< Glib::RefPtr<Gdk::Pixbuf> >(
treerow[ treeview_operations_columns .status_icon ] ) .clear() ;
break ;
}
pulse = operationdetail .fraction < 0 ;
//update the gui elements..
this ->operationdetail = operationdetail ;
if ( operationdetail .get_status() == STATUS_EXECUTE )
label_current_sub_text = operationdetail .get_description() ;
dispatcher_update_gui_elements() ;
}
//check description and update if necessary
//FIXME: it feels quite inefficient to do this for every row, maybe we should add a new status which indicates
//this row may be changed and should be checked...(otoh, if/when we start displaying the output of the command
//in realtime almost every row is going to need this and such a status might become useless...)
if ( operation_detail .get_description() != treerow[ treeview_operations_columns .operation_description ] )
treerow[ treeview_operations_columns .operation_description ] = operation_detail .get_description() ;
if ( operation_detail .fraction >= 0 )
else//it's an new od which needs to be added to the model.
{
pulse = false ;
progressbar_current .set_fraction( operation_detail .fraction ) ;
progressbar_current .set_text( operation_detail .progress_text ) ;
}
else
pulse = true ;
unsigned int pos = operationdetail .get_treepath() .rfind( ":" ) ;
if ( pos >= 0 && pos < operationdetail .get_treepath() .length() )
iter= treestore_operations ->get_iter(
operationdetail .get_treepath() .substr( 0,
operationdetail .get_treepath() .rfind( ":" ) ) ) ;
else
iter= treestore_operations ->get_iter( operationdetail .get_treepath() ) ;
//and update the children.. (since sometimes freshly added treerows are not appended yet to the children() list
//we also check if t < treerow .children() .size())
for ( unsigned int t = 0 ; t < operation_detail .sub_details .size() && t < treerow .children() .size() ; t++ )
update_operation_details( treerow .children()[ t ], operation_detail .sub_details[ t ] ) ;
if ( iter)
{
treestore_operations ->append( static_cast<Gtk::TreeRow>( *iter) .children() ) ;
on_signal_update( operationdetail ) ;
}
}
}
void Dialog_Progress::dispatcher_on_update_gui_elements()
{
label_current_sub .set_markup( "<i>" + label_current_sub_text + "</i>\n" ) ;
if ( operationdetail .fraction >= 0 )
{
progressbar_current .set_fraction( operationdetail .fraction ) ;
progressbar_current .set_text( operationdetail .progress_text ) ;
}
}
void Dialog_Progress::on_signal_show()
{
for ( t = 0 ; t < operations .size() && succes && ! cancel ; t++ )
{
operations[ t ] ->operation_detail .signal_update .connect(
sigc::mem_fun( this, &Dialog_Progress::on_signal_update ) ) ;
label_current .set_markup( "<b>" + operations[ t ] ->description + "</b>" ) ;
progressbar_all .set_text( String::ucompose( _("%1 of %2 operations completed"), t, operations .size() ) ) ;
@ -192,8 +201,7 @@ void Dialog_Progress::on_signal_show()
treerow = treestore_operations ->children()[ t ] ;
//set status to 'execute'
operations[ t ] ->operation_detail .status = STATUS_EXECUTE ;
update_operation_details( treerow, operations[ t ] ->operation_detail ) ;
operations[ t ] ->operation_detail .set_status( STATUS_EXECUTE ) ;
//set focus...
treeview_operations .set_cursor( static_cast<Gtk::TreePath>( treerow ) ) ;
@ -202,20 +210,8 @@ void Dialog_Progress::on_signal_show()
running = true ;
pthread_create( & pthread, NULL, Dialog_Progress::static_pthread_apply_operation, this );
int ms = 200 ; //'refreshrate' of the treeview..
while ( running )
{
if ( ms >= 200 )
{
update_operation_details( treerow, operations[ t ] ->operation_detail ) ;
if ( operations[ t ] ->operation_detail .sub_details .size() > 0 )
label_current_sub .set_markup(//FIXME: move this to update_operation_details and
//show every sub that has STATUS_EXECUTE...
"<i>" +
operations[ t ] ->operation_detail .sub_details .back() .get_description() +
"</i>\n" ) ;
ms = 0 ;
}
if ( pulse )
progressbar_current .pulse() ;
@ -223,12 +219,10 @@ void Dialog_Progress::on_signal_show()
Gtk::Main::iteration();
usleep( 10000 ) ;
ms += 10 ;
}
//set status (succes/error) for this operation
operations[ t ] ->operation_detail .status = succes ? STATUS_SUCCES : STATUS_ERROR ;
update_operation_details( treerow, operations[ t ] ->operation_detail ) ;
operations[ t ] ->operation_detail .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
}
//add save button
@ -355,10 +349,10 @@ void Dialog_Progress::on_save()
}
}
void Dialog_Progress::echo_operation_details( const OperationDetail & operation_detail, std::ofstream & out )
void Dialog_Progress::echo_operation_details( const OperationDetail & operationdetail, std::ofstream & out )
{
//replace '\n' with '<br>'
Glib::ustring temp = operation_detail .get_description() ;
Glib::ustring temp = operationdetail .get_description() ;
for ( unsigned int index = temp .find( "\n" ) ; index < temp .length() ; index = temp .find( "\n" ) )
temp .replace( index, 1, "<BR />" ) ;
@ -369,10 +363,10 @@ void Dialog_Progress::echo_operation_details( const OperationDetail & operation_
out << temp ;
//show status...
if ( operation_detail .status != STATUS_NONE )
if ( operationdetail .get_status() != STATUS_NONE )
{
out << "&nbsp;&nbsp;&nbsp;&nbsp;" ;
switch ( operation_detail .status )
switch ( operationdetail .get_status() )
{
case STATUS_EXECUTE:
out << "( EXECUTING )" ;
@ -383,6 +377,12 @@ void Dialog_Progress::echo_operation_details( const OperationDetail & operation_
case STATUS_ERROR:
out << "( ERROR )" ;
break ;
case STATUS_INFO:
out << "( INFO )" ;
break ;
case STATUS_N_A:
out << "( N/A )" ;
break ;
default:
break ;
@ -393,19 +393,18 @@ void Dialog_Progress::echo_operation_details( const OperationDetail & operation_
out << "</TD>" << std::endl ;
out << "</TR>" << std::endl ;
if ( operation_detail .sub_details. size() )
if ( operationdetail .get_childs(). size() )
{
out << "<TR>" << std::endl ;
out << "<TD>&nbsp;&nbsp;&nbsp;&nbsp;</TD>" << std::endl ;
out << "<TD>" << std::endl ;
for ( unsigned int t = 0 ; t < operation_detail .sub_details .size() ; t++ )
echo_operation_details( operation_detail .sub_details[ t ], out ) ;
for ( unsigned int t = 0 ; t < operationdetail .get_childs() .size() ; t++ )
echo_operation_details( operationdetail .get_childs()[ t ], out ) ;
out << "</TD>" << std::endl ;
out << "</TR>" << std::endl ;
}
out << "</TABLE>" << std::endl ;
}

View file

@ -25,17 +25,17 @@ FileSystem::FileSystem()
{
}
int FileSystem::execute_command( const Glib::ustring & command, std::vector<OperationDetail> & operation_details )
int FileSystem::execute_command( const Glib::ustring & command, OperationDetail & operationdetail )
{
operation_details .push_back( OperationDetail( command, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
operationdetail .add_child( OperationDetail( command, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
int exit_status = Utils::execute_command( command, output, error ) ;
if ( ! output .empty() )
operation_details .back() .sub_details .push_back( OperationDetail( output, STATUS_NONE, FONT_ITALIC ) ) ;
operationdetail .get_last_child() .add_child( OperationDetail( output, STATUS_NONE, FONT_ITALIC ) ) ;
if ( ! error .empty() )
operation_details .back() .sub_details .push_back( OperationDetail( error, STATUS_NONE, FONT_ITALIC ) ) ;
operationdetail .get_last_child() .add_child( OperationDetail( error, STATUS_NONE, FONT_ITALIC ) ) ;
return exit_status ;
}

View file

@ -232,6 +232,8 @@ bool GParted_Core::snap_to_cylinder( const Device & device, Partition & partitio
{
if ( ! partition .strict )
{
//FIXME: this doesn't work to well, when dealing with layouts which contain an extended partition
//because of the metadata length % cylindersize isn't always 0
Sector diff = partition .sector_start % device .cylsize ;
if ( diff )
{
@ -288,7 +290,7 @@ bool GParted_Core::apply_operation_to_disk( Operation * operation )
if ( operation ->partition_original .status == GParted::STAT_COPY )
{
succes = false ;
operation ->operation_detail .sub_details .push_back(
operation ->operation_detail .add_child(
OperationDetail( String::ucompose( _("find real path of %1"),
operation ->partition_original .get_path() ) ) ) ;
@ -307,7 +309,7 @@ bool GParted_Core::apply_operation_to_disk( Operation * operation )
free( lp_path ) ;
succes = true ;
operation ->operation_detail .sub_details .back() .sub_details .push_back(
operation ->operation_detail .get_last_child() .add_child(
OperationDetail( String::ucompose( _("path: %1"),
operation ->partition_new .get_path() ),
STATUS_NONE,
@ -317,30 +319,28 @@ bool GParted_Core::apply_operation_to_disk( Operation * operation )
close_device_and_disk() ;
}
operation ->operation_detail .sub_details .back() .status = succes ? STATUS_SUCCES : STATUS_ERROR ;
operation ->operation_detail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
}
if ( succes )
switch ( operation ->type )
{
case OPERATION_DELETE:
succes = Delete( operation ->partition_original,
operation ->operation_detail .sub_details ) ;
succes = Delete( operation ->partition_original, operation ->operation_detail ) ;
break ;
case OPERATION_CREATE:
succes = create( operation ->device,
operation ->partition_new,
operation ->operation_detail .sub_details ) ;
operation ->operation_detail ) ;
break ;
case OPERATION_RESIZE_MOVE:
succes = resize_move( operation ->device,
operation ->partition_original,
operation ->partition_new,
operation ->operation_detail .sub_details ) ;
operation ->operation_detail ) ;
break ;
case OPERATION_FORMAT:
succes = format( operation ->partition_new,
operation ->operation_detail .sub_details ) ;
succes = format( operation ->partition_new, operation ->operation_detail ) ;
break ;
case OPERATION_COPY:
//when copying to an existing partition we have to change the 'copy of..' to a valid path
@ -348,17 +348,16 @@ bool GParted_Core::apply_operation_to_disk( Operation * operation )
succes = copy( static_cast<OperationCopy*>( operation ) ->partition_copied,
operation ->partition_new,
static_cast<OperationCopy*>( operation ) ->partition_copied .get_length(),
operation ->operation_detail .sub_details ) ;
operation ->operation_detail ) ;
break ;
}
if ( libparted_messages .size() > 0 )
{
operation ->operation_detail .sub_details .push_back(
OperationDetail( _("libparted messages"), STATUS_INFO ) ) ;
operation ->operation_detail .add_child( OperationDetail( _("libparted messages"), STATUS_INFO ) ) ;
for ( unsigned int t = 0 ; t < libparted_messages .size() ; t++ )
operation ->operation_detail .sub_details .back() .sub_details .push_back(
operation ->operation_detail .get_last_child() .add_child(
OperationDetail( libparted_messages[ t ], STATUS_NONE, FONT_ITALIC ) ) ;
}
@ -840,7 +839,7 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
{
case GParted::FS::EXTERNAL :
if ( set_proper_filesystem( partitions[ t ] .filesystem ) )
p_filesystem ->Set_Used_Sectors( partitions[ t ] ) ;
p_filesystem ->set_used_sectors( partitions[ t ] ) ;
break ;
case GParted::FS::LIBPARTED :
LP_set_used_sectors( partitions[ t ] ) ;
@ -898,31 +897,27 @@ void GParted_Core::set_flags( Partition & partition )
partition .flags .push_back( ped_partition_flag_get_name( flags[ t ] ) ) ;
}
bool GParted_Core::create( const Device & device,
Partition & new_partition,
std::vector<OperationDetail> & operation_details )
bool GParted_Core::create( const Device & device, Partition & new_partition, OperationDetail & operationdetail )
{
if ( new_partition .type == GParted::TYPE_EXTENDED )
{
return create_partition( new_partition, operation_details ) ;
return create_partition( new_partition, operationdetail ) ;
}
else if ( create_partition( new_partition, operation_details, get_fs( new_partition .filesystem ) .MIN ) )
else if ( create_partition( new_partition, operationdetail, get_fs( new_partition .filesystem ) .MIN ) )
{
if ( new_partition .filesystem == GParted::FS_UNFORMATTED )
return true ;
else
return set_partition_type( new_partition, operation_details ) &&
create_filesystem( new_partition, operation_details ) ;
return set_partition_type( new_partition, operationdetail ) &&
create_filesystem( new_partition, operationdetail ) ;
}
return false ;
}
bool GParted_Core::create_partition( Partition & new_partition,
std::vector<OperationDetail> & operation_details,
Sector min_size )
bool GParted_Core::create_partition( Partition & new_partition, OperationDetail & operationdetail, Sector min_size )
{
operation_details .push_back( OperationDetail( _("create empty partition") ) ) ;
operationdetail .add_child( OperationDetail( _("create empty partition") ) ) ;
new_partition .partition_number = 0 ;
@ -989,7 +984,7 @@ bool GParted_Core::create_partition( Partition & new_partition,
new_partition .sector_start = lp_partition ->geom .start ;
new_partition .sector_end = lp_partition ->geom .end ;
operation_details .back() .sub_details .push_back( OperationDetail(
operationdetail .get_last_child() .add_child( OperationDetail(
String::ucompose( _("path: %1"), new_partition .get_path() ) + "\n" +
String::ucompose( _("start: %1"), new_partition .sector_start ) + "\n" +
String::ucompose( _("end: %1"), new_partition .sector_end ) + "\n" +
@ -1018,23 +1013,23 @@ bool GParted_Core::create_partition( Partition & new_partition,
)
)
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
return true ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
return false ;
}
}
bool GParted_Core::create_filesystem( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool GParted_Core::create_filesystem( const Partition & partition, OperationDetail & operationdetail )
{
operation_details .push_back( OperationDetail( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( partition .filesystem ) ) ) ) ;
operationdetail .add_child( OperationDetail( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( partition .filesystem ) ) ) ) ;
bool succes = false ;
switch ( get_fs( partition .filesystem ) .create )
@ -1047,25 +1042,24 @@ bool GParted_Core::create_filesystem( const Partition & partition, std::vector<O
break ;
case GParted::FS::EXTERNAL:
succes = set_proper_filesystem( partition .filesystem ) &&
p_filesystem ->Create( partition, operation_details .back() .sub_details ) ;
p_filesystem ->create( partition, operationdetail .get_last_child() ) ;
break ;
}
operation_details .back() .status = succes ? STATUS_SUCCES : STATUS_ERROR ;
operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
return succes ;
}
bool GParted_Core::format( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool GParted_Core::format( const Partition & partition, OperationDetail & operationdetail )
{
//remove all filesystem signatures...
erase_filesystem_signatures( partition ) ;
return set_partition_type( partition, operation_details ) &&
create_filesystem( partition, operation_details ) ;
return set_partition_type( partition, operationdetail ) && create_filesystem( partition, operationdetail ) ;
}
bool GParted_Core::Delete( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool GParted_Core::Delete( const Partition & partition, OperationDetail & operationdetail )
{
bool return_value = false ;
@ -1088,42 +1082,42 @@ bool GParted_Core::Delete( const Partition & partition, std::vector<OperationDet
bool GParted_Core::resize_move( const Device & device,
const Partition & partition_old,
Partition & partition_new,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
if ( calculate_exact_geom( partition_old, partition_new, operation_details ) )
if ( calculate_exact_geom( partition_old, partition_new, operationdetail ) )
{
//extended is a special case..
if ( partition_old .type == GParted::TYPE_EXTENDED )
return resize_move_partition( partition_old, partition_new, operation_details ) ;
return resize_move_partition( partition_old, partition_new, operationdetail ) ;
//see if we need move or resize..
if ( partition_new .sector_start == partition_old .sector_start )
return resize( partition_old, partition_new, operation_details ) ;
return resize( partition_old, partition_new, operationdetail ) ;
else if ( partition_new .get_length() > partition_old .get_length() )
{
//first move, then grow...
Partition temp = partition_new ;
temp .sector_end = temp .sector_start + partition_old .get_length() -1 ;
return calculate_exact_geom( partition_old, temp, operation_details, temp .get_length() ) &&
move( device, partition_old, temp, operation_details ) &&
resize( temp, partition_new, operation_details ) ;
return calculate_exact_geom( partition_old, temp, operationdetail, temp .get_length() ) &&
move( device, partition_old, temp, operationdetail ) &&
resize( temp, partition_new, operationdetail ) ;
}
else if ( partition_new .get_length() < partition_old .get_length() )
{
//first shrink, then move..
Partition temp = partition_old ;
temp .sector_end = partition_old .sector_start + partition_new .get_length() -1 ;
return calculate_exact_geom( partition_old, temp, operation_details ) &&
resize( partition_old, temp, operation_details ) &&
calculate_exact_geom( temp, partition_new, operation_details, temp .get_length() ) &&
move( device, temp, partition_new, operation_details ) ;
//FIXME: shrink and move of fat32 fs in 1 operation throws path not found errors
return calculate_exact_geom( partition_old, temp, operationdetail ) &&
resize( partition_old, temp, operationdetail ) &&
calculate_exact_geom( temp, partition_new, operationdetail, temp .get_length() ) &&
move( device, temp, partition_new, operationdetail ) ;
}
else
return calculate_exact_geom(
partition_old, partition_new, operation_details, partition_old .get_length() ) &&
move( device, partition_old, partition_new, operation_details ) ;
partition_old, partition_new, operationdetail, partition_old .get_length() ) &&
move( device, partition_old, partition_new, operationdetail ) ;
}
return false ;
@ -1132,34 +1126,32 @@ bool GParted_Core::resize_move( const Device & device,
bool GParted_Core::move( const Device & device,
const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
return check_repair_filesystem( partition_old, operation_details ) &&
move_filesystem( partition_old, partition_new, operation_details ) &&
resize_move_partition( partition_old,
partition_new,
operation_details ) &&
check_repair_filesystem( partition_new, operation_details ) &&
maximize_filesystem( partition_new, operation_details ) ;
return check_repair_filesystem( partition_old, operationdetail ) &&
move_filesystem( partition_old, partition_new, operationdetail ) &&
resize_move_partition( partition_old, partition_new, operationdetail ) &&
check_repair_filesystem( partition_new, operationdetail ) &&
maximize_filesystem( partition_new, operationdetail ) ;
}
bool GParted_Core::move_filesystem( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
if ( partition_new .sector_start < partition_old .sector_start )
operation_details .push_back( OperationDetail( _("move filesystem to the left") ) ) ;
operationdetail .add_child( OperationDetail( _("move filesystem to the left") ) ) ;
else if ( partition_new .sector_start > partition_old .sector_start )
operation_details .push_back( OperationDetail( _("move filesystem to the right") ) ) ;
operationdetail .add_child( OperationDetail( _("move filesystem to the right") ) ) ;
else
{
operation_details .push_back( OperationDetail( _("move filesystem") ) ) ;
operation_details .back() .sub_details .push_back(
operationdetail .add_child( OperationDetail( _("move filesystem") ) ) ;
operationdetail .get_last_child() .add_child(
OperationDetail( _("new and old filesystem have the same positition. skipping this operation"),
STATUS_NONE,
FONT_ITALIC ) ) ;
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
return true ;
}
@ -1170,33 +1162,33 @@ bool GParted_Core::move_filesystem( const Partition & partition_old,
break ;
case GParted::FS::GPARTED:
succes = move_filesystem_using_gparted( partition_old,
partition_new,
operation_details .back() .sub_details ) ;
partition_new,
operationdetail .get_last_child() ) ;
break ;
case GParted::FS::LIBPARTED:
succes = resize_move_filesystem_using_libparted( partition_old,
partition_new,
operation_details .back() .sub_details ) ;
operationdetail .get_last_child() ) ;
break ;
case GParted::FS::EXTERNAL:
break ;
}
operation_details .back() .status = succes ? STATUS_SUCCES : STATUS_ERROR ;
operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
return succes ;
}
bool GParted_Core::move_filesystem_using_gparted( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
operation_details .push_back( OperationDetail( _("using internal algorithm"), STATUS_NONE ) ) ;
operationdetail .add_child( OperationDetail( _("using internal algorithm"), STATUS_NONE ) ) ;
CopyType copytype = partition_new .sector_start < partition_old .sector_start ? START_TO_END : END_TO_START ;
Sector optimal_blocksize, offset ;
return find_optimal_blocksize( partition_old, partition_new, copytype, optimal_blocksize, offset, operation_details )
return find_optimal_blocksize( partition_old, partition_new, copytype, optimal_blocksize, offset, operationdetail )
&&
copy_blocks( partition_old .device_path,
partition_new .device_path,
@ -1204,15 +1196,15 @@ bool GParted_Core::move_filesystem_using_gparted( const Partition & partition_ol
partition_new .sector_start + offset,
optimal_blocksize,
partition_old .get_length() - offset,
operation_details,
operationdetail,
copytype ) ;
}
bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
operation_details .push_back( OperationDetail( _("using libparted"), STATUS_NONE ) ) ;
operationdetail .add_child( OperationDetail( _("using libparted"), STATUS_NONE ) ) ;
bool return_value = false ;
if ( open_device_and_disk( partition_old .device_path ) )
@ -1245,28 +1237,25 @@ bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & par
bool GParted_Core::resize( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
bool succes = false ;
if ( check_repair_filesystem( partition_new, operation_details ) )
if ( check_repair_filesystem( partition_new, operationdetail ) )
{
succes = true ;
if ( succes && partition_new .get_length() < partition_old .get_length() )
succes = resize_filesystem( partition_old, partition_new, operation_details ) ;
succes = resize_filesystem( partition_old, partition_new, operationdetail ) ;
if ( succes )
succes = resize_move_partition(
partition_old,
partition_new,
operation_details ) ;
succes = resize_move_partition( partition_old, partition_new, operationdetail ) ;
//these 3 are always executed, however, if 1 of them fails the whole operation fails
if ( ! check_repair_filesystem( partition_new, operation_details ) )
//these 2 are always executed, however, if 1 of them fails the whole operation fails
if ( ! check_repair_filesystem( partition_new, operationdetail ) )
succes = false ;
//expand filesystem to fit exactly in partition
if ( ! maximize_filesystem( partition_new, operation_details ) )
if ( ! maximize_filesystem( partition_new, operationdetail ) )
succes = false ;
return succes ;
@ -1277,7 +1266,7 @@ bool GParted_Core::resize( const Partition & partition_old,
bool GParted_Core::resize_move_partition( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
//i'm not too happy with this, but i think it is the correct way from a i18n POV
enum Action
@ -1343,16 +1332,16 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
Utils::format_size( partition_old .get_length() ),
Utils::format_size( partition_new .get_length() ) ) ;
operation_details .push_back( OperationDetail( description ) ) ;
operationdetail .add_child( OperationDetail( description ) ) ;
if ( action == NONE )
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .add_child(
OperationDetail( _("new and old partition have the same size and positition. continuing anyway"),
STATUS_NONE,
FONT_ITALIC ) ) ;
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .add_child(
OperationDetail(
String::ucompose( _("old start: %1"), partition_old .sector_start ) + "\n" +
String::ucompose( _("old end: %1"), partition_old .sector_end ) + "\n" +
@ -1409,7 +1398,7 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
if ( return_value )
{
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .add_child(
OperationDetail(
String::ucompose( _("new start: %1"), new_start ) + "\n" +
String::ucompose( _("new end: %1"), new_end ) + "\n" +
@ -1422,13 +1411,13 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
if ( partition_old .type == GParted::TYPE_EXTENDED )
{
operation_details .back() .status = return_value ? STATUS_SUCCES : STATUS_ERROR ;
operationdetail .get_last_child() .set_status( return_value ? STATUS_SUCCES : STATUS_ERROR ) ;
return return_value ;
}
else
{
return_value &= wait_for_node( partition_new .get_path() ) ;
operation_details .back() .status = return_value ? STATUS_SUCCES : STATUS_ERROR ;
operationdetail .get_last_child() .set_status( return_value ? STATUS_SUCCES : STATUS_ERROR ) ;
return return_value ;
}
@ -1436,7 +1425,7 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
bool GParted_Core::resize_filesystem( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
OperationDetail & operationdetail,
bool fill_partition )
{
//by default 'grow' to accomodate expand_filesystem()
@ -1446,15 +1435,15 @@ bool GParted_Core::resize_filesystem( const Partition & partition_old,
{
if ( partition_new .get_length() < partition_old .get_length() )
{
operation_details .push_back( OperationDetail( _("shrink filesystem") ) ) ;
operationdetail .add_child( OperationDetail( _("shrink filesystem") ) ) ;
action = get_fs( partition_old .filesystem ) .shrink ;
}
else if ( partition_new .get_length() > partition_old .get_length() )
operation_details .push_back( OperationDetail( _("grow filesystem") ) ) ;
operationdetail .add_child( OperationDetail( _("grow filesystem") ) ) ;
else
{
operation_details .push_back( OperationDetail( _("resize filesystem") ) ) ;
operation_details .back() .sub_details .push_back(
operationdetail .add_child( OperationDetail( _("resize filesystem") ) ) ;
operationdetail .get_last_child() .add_child(
OperationDetail(
_("new and old filesystem have the same size and positition. continuing anyway"),
STATUS_NONE,
@ -1472,53 +1461,52 @@ bool GParted_Core::resize_filesystem( const Partition & partition_old,
case GParted::FS::LIBPARTED:
succes = resize_move_filesystem_using_libparted( partition_old,
partition_new,
operation_details .back() .sub_details ) ;
operationdetail .get_last_child() ) ;
break ;
case GParted::FS::EXTERNAL:
succes = set_proper_filesystem( partition_new .filesystem ) &&
p_filesystem ->Resize( partition_new,
operation_details .back() .sub_details,
fill_partition ) ;
p_filesystem ->resize( partition_new,
operationdetail .get_last_child(),
fill_partition ) ;
break ;
}
operation_details .back() .status = succes ? STATUS_SUCCES : STATUS_ERROR ;
operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
return succes ;
}
bool GParted_Core::maximize_filesystem( const Partition & partition,
std::vector<OperationDetail> & operation_details )
bool GParted_Core::maximize_filesystem( const Partition & partition, OperationDetail & operationdetail )
{
operation_details .push_back( OperationDetail( _("grow filesystem to fill the partition") ) ) ;
operationdetail .add_child( OperationDetail( _("grow filesystem to fill the partition") ) ) ;
if ( get_fs( partition .filesystem ) .grow == GParted::FS::NONE )
{
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .add_child(
OperationDetail( _("growing is not available for this filesystem"),
STATUS_NONE,
FONT_ITALIC ) ) ;
operation_details .back() .status = STATUS_N_A ;
operationdetail .get_last_child() .set_status( STATUS_N_A ) ;
return true ;
}
return resize_filesystem( partition, partition, operation_details, true ) ;
return resize_filesystem( partition, partition, operationdetail, true ) ;
}
bool GParted_Core::copy( const Partition & partition_src,
Partition & partition_dest,
Sector min_size,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
if ( check_repair_filesystem( partition_src, operation_details ) )
if ( check_repair_filesystem( partition_src, operationdetail ) )
{
bool succes = true ;
if ( partition_dest .status == GParted::STAT_COPY )
succes = create_partition( partition_dest, operation_details, min_size ) ;
succes = create_partition( partition_dest, operationdetail, min_size ) ;
if ( succes && set_partition_type( partition_dest, operation_details ) )
if ( succes && set_partition_type( partition_dest, operationdetail ) )
{
operation_details .push_back( OperationDetail(
operationdetail .add_child( OperationDetail(
String::ucompose( _("copy filesystem of %1 to %2"),
partition_src .get_path(),
partition_dest .get_path() ) ) ) ;
@ -1529,7 +1517,7 @@ bool GParted_Core::copy( const Partition & partition_src,
case GParted::FS::GPARTED :
succes = copy_filesystem( partition_src,
partition_dest,
operation_details .back() .sub_details ) ;
operationdetail .get_last_child() ) ;
break ;
case GParted::FS::LIBPARTED :
@ -1538,9 +1526,9 @@ bool GParted_Core::copy( const Partition & partition_src,
case GParted::FS::EXTERNAL :
succes = set_proper_filesystem( partition_dest .filesystem ) &&
p_filesystem ->Copy( partition_src .get_path(),
p_filesystem ->copy( partition_src .get_path(),
partition_dest .get_path(),
operation_details .back() .sub_details ) ;
operationdetail .get_last_child() ) ;
break ;
default :
@ -1548,11 +1536,11 @@ bool GParted_Core::copy( const Partition & partition_src,
break ;
}
operation_details .back() .status = succes ? STATUS_SUCCES : STATUS_ERROR ;
operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
return ( succes &&
check_repair_filesystem( partition_dest, operation_details ) &&
maximize_filesystem( partition_dest, operation_details ) ) ;
check_repair_filesystem( partition_dest, operationdetail ) &&
maximize_filesystem( partition_dest, operationdetail ) ) ;
}
}
@ -1561,7 +1549,7 @@ bool GParted_Core::copy( const Partition & partition_src,
bool GParted_Core::copy_filesystem( const Partition & partition_src,
const Partition & partition_dst,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
Sector optimal_blocksize, offset ;
@ -1570,7 +1558,7 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
START_TO_END,
optimal_blocksize,
offset,
operation_details )
operationdetail )
&&
copy_blocks( partition_src .device_path,
partition_dst .device_path,
@ -1578,13 +1566,13 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
partition_dst .sector_start + offset,
optimal_blocksize,
partition_src .get_length() - offset,
operation_details,
operationdetail,
START_TO_END ) ;
}
bool GParted_Core::check_repair_filesystem( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool GParted_Core::check_repair_filesystem( const Partition & partition, OperationDetail & operationdetail )
{
operation_details .push_back( OperationDetail(
operationdetail .add_child( OperationDetail(
String::ucompose( _("check filesystem on %1 for errors and (if possible) fix them"),
partition .get_path() ) ) ) ;
@ -1592,10 +1580,12 @@ bool GParted_Core::check_repair_filesystem( const Partition & partition, std::ve
switch ( get_fs( partition .filesystem ) .check )
{
case GParted::FS::NONE:
operation_details .back() .sub_details .push_back(
OperationDetail( _("checking is not available for this filesystem"), STATUS_NONE, FONT_ITALIC ) ) ;
operationdetail .get_last_child() .add_child(
OperationDetail( _("checking is not available for this filesystem"),
STATUS_NONE,
FONT_ITALIC ) ) ;
operation_details .back() .status = STATUS_N_A ;
operationdetail .get_last_child() .set_status( STATUS_N_A ) ;
return true ;
break ;
@ -1605,20 +1595,19 @@ bool GParted_Core::check_repair_filesystem( const Partition & partition, std::ve
break ;
case GParted::FS::EXTERNAL:
succes = set_proper_filesystem( partition .filesystem ) &&
p_filesystem ->Check_Repair( partition, operation_details .back() .sub_details ) ;
p_filesystem ->check_repair( partition, operationdetail .get_last_child() ) ;
break ;
}
operation_details .back() .status = succes ? STATUS_SUCCES : STATUS_ERROR ;
operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
return succes ;
}
bool GParted_Core::set_partition_type( const Partition & partition,
std::vector<OperationDetail> & operation_details )
bool GParted_Core::set_partition_type( const Partition & partition, OperationDetail & operationdetail )
{
operation_details .push_back( OperationDetail(
String::ucompose( _("set partitiontype on %1"), partition .get_path() ) ) ) ;
operationdetail .add_child( OperationDetail(
String::ucompose( _("set partitiontype on %1"), partition .get_path() ) ) ) ;
bool return_value = false ;
@ -1637,7 +1626,7 @@ bool GParted_Core::set_partition_type( const Partition & partition,
if ( lp_partition && ped_partition_set_system( lp_partition, fs_type ) && commit() )
{
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .add_child(
OperationDetail( String::ucompose( _("new partitiontype: %1"),
lp_partition ->fs_type ->name ),
STATUS_NONE,
@ -1650,7 +1639,7 @@ bool GParted_Core::set_partition_type( const Partition & partition,
close_device_and_disk() ;
}
operation_details .back() .status = return_value ? STATUS_SUCCES : STATUS_ERROR ;
operationdetail .get_last_child() .set_status( return_value ? STATUS_SUCCES : STATUS_ERROR ) ;
return return_value ;
}
@ -1697,7 +1686,7 @@ bool GParted_Core::find_optimal_blocksize( const Partition & partition_old,
CopyType copytype,
Sector & optimal_blocksize,
Sector & offset,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{//FIXME, this probing is actually quite clumsy and suboptimal..
//find out if there is a better way to determine a (close to) optimal blocksize...
bool succes = true ;
@ -1707,7 +1696,7 @@ bool GParted_Core::find_optimal_blocksize( const Partition & partition_old,
if ( partition_old .get_length() > 100000 )
{
operation_details .push_back( OperationDetail( _("finding optimal blocksize"), STATUS_NONE ) ) ;
operationdetail .add_child( OperationDetail( _("finding optimal blocksize"), STATUS_NONE ) ) ;
std::clock_t clockticks_start, smallest_ticks = -1 ;
@ -1728,9 +1717,8 @@ bool GParted_Core::find_optimal_blocksize( const Partition & partition_old,
partition_new .sector_start + offset,
blocksizes[ t ],
20000,
operation_details .back() .sub_details,
copytype,
false ) ;
operationdetail .get_last_child(),
copytype ) ;
if ( (std::clock() - clockticks_start) < smallest_ticks || smallest_ticks == -1 )
{
@ -1738,7 +1726,7 @@ bool GParted_Core::find_optimal_blocksize( const Partition & partition_old,
optimal_blocksize = blocksizes[ t ] ;
}
operation_details .back() .sub_details .back() .sub_details .push_back( OperationDetail(
operationdetail .get_last_child() .get_last_child() .add_child( OperationDetail(
String::ucompose( _("%1 clockticks"), std::clock() - clockticks_start ),
STATUS_NONE,
FONT_ITALIC ) ) ;
@ -1746,7 +1734,7 @@ bool GParted_Core::find_optimal_blocksize( const Partition & partition_old,
offset += 20000 ;
}
operation_details .back() .sub_details .push_back( OperationDetail(
operationdetail .get_last_child() .add_child( OperationDetail(
String::ucompose( _("optimal blocksize is %1 sectors (%2)"),
optimal_blocksize,
Utils::format_size( optimal_blocksize ) ) ,
@ -1762,12 +1750,11 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device,
Sector dst_start,
Sector blocksize,
Sector sectors,
std::vector<OperationDetail> & operation_details,
CopyType copytype,
bool show_progress )
OperationDetail & operationdetail,
CopyType copytype )
{
operation_details .push_back( OperationDetail(
String::ucompose( _("copy %1 sectors using a blocksize of %2 sectors"), sectors, blocksize ), STATUS_NONE ) ) ;
operationdetail .add_child( OperationDetail(
String::ucompose( _("copy %1 sectors using a blocksize of %2 sectors"), sectors, blocksize ) ) ) ;
bool succes = false ;
PedDevice *lp_device_src, *lp_device_dst ;
@ -1783,9 +1770,10 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device,
{
ped_device_sync( lp_device_dst ) ;
//add an empty sub which we will constantly update in the loop
operation_details .back() .sub_details .push_back( OperationDetail( "", STATUS_NONE ) ) ;
operationdetail .get_last_child() .add_child( OperationDetail( "", STATUS_NONE ) ) ;
std::time_t time_start = std::time(NULL) ;
std::time_t time_start, time_last_progress_update ;
time_start = time_last_progress_update = std::time(NULL) ;
Sector t ;
if ( copytype == START_TO_END )
{
@ -1799,12 +1787,16 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device,
blocksize,
error_message ) )
break ;
if ( show_progress && (std::time(NULL) - time_start) > 1 )
if ( (std::time(NULL) - time_last_progress_update) >= 1 )
{
set_progress_info( sectors,
t + blocksize,
time_start,
operation_details .back() .sub_details .back() ) ;
operationdetail .get_last_child() .get_last_child() ) ;
time_last_progress_update = std::time(NULL) ;
}
}
if ( rest_sectors > 0 &&
@ -1830,11 +1822,15 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device,
error_message ) )
break ;
if ( show_progress && (std::time(NULL) - time_start) > 1 )
if ( (std::time(NULL) - time_last_progress_update) >= 1 )
{
set_progress_info( sectors,
t + blocksize,
time_start,
operation_details .back() .sub_details .back() ) ;
operationdetail .get_last_child() .get_last_child() ) ;
time_last_progress_update = std::time(NULL) ;
}
}
if ( rest_sectors > 0 &&
@ -1850,17 +1846,17 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device,
//final description
operation_details .back() .sub_details .back() .set_description(
operationdetail .get_last_child() .get_last_child() .set_description(
String::ucompose( _("%1 of %2 copied"), t, sectors ), FONT_ITALIC ) ;
//reset fraction to -1 to make room for a new one (or a pulsebar)
operation_details .back() .sub_details .back() .fraction = -1 ;
operationdetail .get_last_child() .get_last_child() .fraction = -1 ;
if ( t == sectors )
succes = true ;
if ( ! succes && ! error_message .empty() )
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .add_child(
OperationDetail( error_message, STATUS_NONE, FONT_ITALIC ) ) ;
//close and destroy the devices..
@ -1874,6 +1870,8 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device,
}
}
operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
return succes ;
}
@ -1905,17 +1903,17 @@ bool GParted_Core::copy_block( PedDevice * lp_device_src,
bool GParted_Core::calculate_exact_geom( const Partition & partition_old,
Partition & partition_new,
std::vector<OperationDetail> & operation_details,
OperationDetail & operationdetail,
Sector min_size )
{
operation_details .push_back( OperationDetail(
operationdetail .add_child( OperationDetail(
String::ucompose( _("calculate new size and position of %1"), partition_new .get_path() ) ) ) ;
if ( min_size >= 0 )
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .add_child(
OperationDetail( String::ucompose( _("minimum size: %1"), min_size ), STATUS_NONE ) ) ;
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .add_child(
OperationDetail(
String::ucompose( _("requested start: %1"), partition_new .sector_start ) + "\n" +
String::ucompose( _("requested end: %1"), partition_new .sector_end ) + "\n" +
@ -1969,7 +1967,7 @@ bool GParted_Core::calculate_exact_geom( const Partition & partition_old,
if ( succes )
{
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .add_child(
OperationDetail(
String::ucompose( _("new start: %1"), partition_new .sector_start ) + "\n" +
String::ucompose( _("new end: %1"), partition_new .sector_end ) + "\n" +
@ -1980,7 +1978,7 @@ bool GParted_Core::calculate_exact_geom( const Partition & partition_old,
FONT_ITALIC ) ) ;
}
operation_details .back() .status = succes ? STATUS_SUCCES : STATUS_ERROR ;
operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
return succes ;
}

View file

@ -17,6 +17,7 @@
#include "../include/OperationDetail.h"
#include "../include/Utils.h"
namespace GParted
{
@ -52,11 +53,72 @@ void OperationDetail::set_description( const Glib::ustring & description, Font f
this ->description = "<b><i>" + Glib::Markup::escape_text( description ) + "</i></b>" ;
break ;
}
if ( ! treepath .empty() )
on_update( *this ) ;
}
Glib::ustring OperationDetail::get_description() const
{
return description ;
}
void OperationDetail::set_status( OperationDetailStatus status )
{
if ( this ->status != STATUS_ERROR )
{
this ->status = status ;
on_update( *this ) ;
}
}
OperationDetailStatus OperationDetail::get_status() const
{
return status ;
}
void OperationDetail::set_treepath( const Glib::ustring & treepath )
{
this ->treepath = treepath ;
}
Glib::ustring OperationDetail::get_treepath() const
{
return treepath ;
}
void OperationDetail::add_child( const OperationDetail & operationdetail )
{
sub_details .push_back( operationdetail ) ;
sub_details .back() .set_treepath( treepath + ":" + Utils::num_to_str( sub_details .size() -1 ) ) ;
sub_details .back() .signal_update .connect( sigc::mem_fun( this, &OperationDetail::on_update ) ) ;
on_update( sub_details .back() ) ;
}
std::vector<OperationDetail> & OperationDetail::get_childs()
{
return sub_details ;
}
const std::vector<OperationDetail> & OperationDetail::get_childs() const
{
return sub_details ;
}
OperationDetail & OperationDetail::get_last_child()
{
//little bit of (healthy?) paranoia
if ( sub_details .size() == 0 )
add_child( OperationDetail( "---", STATUS_ERROR ) ) ;
return sub_details .back() ;
}
void OperationDetail::on_update( const OperationDetail & operationdetail )
{
signal_update .emit( operationdetail ) ;
}
} //GParted

View file

@ -51,7 +51,7 @@ FS ext2::get_filesystem_support()
return fs ;
}
void ext2::Set_Used_Sectors( Partition & partition )
void ext2::set_used_sectors( Partition & partition )
{
if ( ! Utils::execute_command( "dumpe2fs -h " + partition .get_path(), output, error, true ) )
{
@ -72,14 +72,12 @@ void ext2::Set_Used_Sectors( Partition & partition )
partition .messages .push_back( error ) ;
}
bool ext2::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool ext2::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkfs.ext2 " + new_partition .get_path(), operation_details ) ;
return ! execute_command( "mkfs.ext2 " + new_partition .get_path(), operationdetail ) ;
}
bool ext2::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool ext2::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
Glib::ustring str_temp = "resize2fs " + partition_new .get_path() ;
@ -87,19 +85,19 @@ bool ext2::Resize( const Partition & partition_new,
str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit(
partition_new .get_length(), GParted::UNIT_KIB ) ) -1, true ) + "K" ;
return ! execute_command( str_temp, operation_details ) ;
return ! execute_command( str_temp, operationdetail ) ;
}
bool ext2::Copy( const Glib::ustring & src_part_path,
bool ext2::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
return true ;
}
bool ext2::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool ext2::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
exit_status = execute_command( "e2fsck -f -y -v " + partition .get_path(), operation_details ) ;
exit_status = execute_command( "e2fsck -f -y -v " + partition .get_path(), operationdetail ) ;
//exitstatus 256 isn't documented, but it's returned when the 'FILESYSTEM IS MODIFIED'
//this is quite normal (especially after a copy) so we let the function return true...

View file

@ -52,7 +52,7 @@ FS ext3::get_filesystem_support()
return fs ;
}
void ext3::Set_Used_Sectors( Partition & partition )
void ext3::set_used_sectors( Partition & partition )
{
if ( ! Utils::execute_command( "dumpe2fs -h " + partition .get_path(), output, error, true ) )
{
@ -73,14 +73,12 @@ void ext3::Set_Used_Sectors( Partition & partition )
partition .messages .push_back( error ) ;
}
bool ext3::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool ext3::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkfs.ext3 " + new_partition .get_path(), operation_details ) ;
return ! execute_command( "mkfs.ext3 " + new_partition .get_path(), operationdetail ) ;
}
bool ext3::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool ext3::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
Glib::ustring str_temp = "resize2fs " + partition_new .get_path() ;
@ -88,19 +86,19 @@ bool ext3::Resize( const Partition & partition_new,
str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit(
partition_new .get_length(), GParted::UNIT_KIB ) ) -1, true ) + "K" ;
return ! execute_command( str_temp, operation_details ) ;
return ! execute_command( str_temp, operationdetail ) ;
}
bool ext3::Copy( const Glib::ustring & src_part_path,
bool ext3::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
return true ;
}
bool ext3::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool ext3::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
exit_status = execute_command( "e2fsck -f -y -v " + partition .get_path(), operation_details ) ;
exit_status = execute_command( "e2fsck -f -y -v " + partition .get_path(), operationdetail ) ;
//exitstatus 256 isn't documented, but it's returned when the 'FILESYSTEM IS MODIFIED'
//this is quite normal (especially after a copy) so we let the function return true...

View file

@ -49,7 +49,7 @@ FS fat16::get_filesystem_support()
return fs ;
}
void fat16::Set_Used_Sectors( Partition & partition )
void fat16::set_used_sectors( Partition & partition )
{
exit_status = Utils::execute_command( "dosfsck -a -v " + partition .get_path(), output, error, true ) ;
if ( exit_status == 0 || exit_status == 1 )
@ -73,28 +73,26 @@ void fat16::Set_Used_Sectors( Partition & partition )
partition .messages .push_back( error ) ;
}
bool fat16::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool fat16::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkdosfs -F16 -v " + new_partition .get_path(), operation_details ) ;
return ! execute_command( "mkdosfs -F16 -v " + new_partition .get_path(), operationdetail ) ;
}
bool fat16::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool fat16::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
return true ;
}
bool fat16::Copy( const Glib::ustring & src_part_path,
bool fat16::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
return true ;
}
bool fat16::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool fat16::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
exit_status = execute_command( "dosfsck -a -w -v " + partition .get_path(), operation_details ) ;
exit_status = execute_command( "dosfsck -a -w -v " + partition .get_path(), operationdetail ) ;
return ( exit_status == 0 || exit_status == 1 ) ;
}

View file

@ -48,7 +48,7 @@ FS fat32::get_filesystem_support()
return fs ;
}
void fat32::Set_Used_Sectors( Partition & partition )
void fat32::set_used_sectors( Partition & partition )
{
exit_status = Utils::execute_command( "dosfsck -a -v " + partition .get_path(), output, error, true ) ;
if ( exit_status == 0 || exit_status == 1 )
@ -72,28 +72,26 @@ void fat32::Set_Used_Sectors( Partition & partition )
partition .messages .push_back( error ) ;
}
bool fat32::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool fat32::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkdosfs -F32 -v " + new_partition .get_path(), operation_details ) ;
return ! execute_command( "mkdosfs -F32 -v " + new_partition .get_path(), operationdetail ) ;
}
bool fat32::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool fat32::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
return true ;
}
bool fat32::Copy( const Glib::ustring & src_part_path,
bool fat32::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
return true ;
}
bool fat32::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool fat32::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
exit_status = execute_command( "dosfsck -a -w -v " + partition .get_path(), operation_details ) ;
exit_status = execute_command( "dosfsck -a -w -v " + partition .get_path(), operationdetail ) ;
return ( exit_status == 0 || exit_status == 1 ) ;
}

View file

@ -41,30 +41,28 @@ FS hfs::get_filesystem_support()
return fs ;
}
void hfs::Set_Used_Sectors( Partition & partition )
void hfs::set_used_sectors( Partition & partition )
{
}
bool hfs::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool hfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "hformat " + new_partition .get_path(), operation_details ) ;
return ! execute_command( "hformat " + new_partition .get_path(), operationdetail ) ;
}
bool hfs::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool hfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
return true ;
}
bool hfs::Copy( const Glib::ustring & src_part_path,
bool hfs::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
return true ;
}
bool hfs::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool hfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
return true ;
}

View file

@ -36,30 +36,28 @@ FS hfsplus::get_filesystem_support()
return fs ;
}
void hfsplus::Set_Used_Sectors( Partition & partition )
void hfsplus::set_used_sectors( Partition & partition )
{
}
bool hfsplus::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool hfsplus::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return true ;
}
bool hfsplus::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool hfsplus::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
return true ;
}
bool hfsplus::Copy( const Glib::ustring & src_part_path,
bool hfsplus::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
return true ;
}
bool hfsplus::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool hfsplus::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
return true ;
}

View file

@ -70,7 +70,7 @@ FS jfs::get_filesystem_support()
return fs ;
}
void jfs::Set_Used_Sectors( Partition & partition )
void jfs::set_used_sectors( Partition & partition )
{
if ( ! Utils::execute_command( "echo dm | jfs_debugfs " + partition .get_path(), output, error, true ) )
{
@ -93,83 +93,81 @@ void jfs::Set_Used_Sectors( Partition & partition )
partition .messages .push_back( error ) ;
}
bool jfs::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool jfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkfs.jfs -q " + new_partition .get_path(), operation_details ) ;
return ! execute_command( "mkfs.jfs -q " + new_partition .get_path(), operationdetail ) ;
}
bool jfs::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool jfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
bool return_value = false ;
Glib::ustring error ;
Glib::ustring TEMP_MP = Glib::get_tmp_dir() + "/gparted_tmp_jfs_mountpoint" ;
//create mountpoint...
operation_details .push_back(
OperationDetail( String::ucompose( _("create temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
operationdetail .add_child( OperationDetail( String::ucompose( _("create temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
if ( ! mkdir( TEMP_MP .c_str(), 0 ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
//mount partition
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("mount %1 on %2"), partition_new .get_path(), TEMP_MP ) ) ) ;
if ( ! execute_command( "mount -v -t jfs " + partition_new .get_path() + " " + TEMP_MP,
operation_details .back() .sub_details ) )
operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
//remount the partition to resize the filesystem
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("remount %1 on %2 with the 'resize' flag enabled"),
partition_new .get_path(), TEMP_MP ) ) ) ;
partition_new .get_path(),
TEMP_MP ) ) ) ;
if ( ! execute_command(
"mount -v -t jfs -o remount,resize " + partition_new .get_path() + " " + TEMP_MP,
operation_details .back() .sub_details ) )
operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
return_value = true ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
}
//and unmount it...
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("unmount %1"), partition_new .get_path() ) ) ) ;
if ( ! execute_command( "umount -v " + partition_new .get_path(),
operation_details .back() .sub_details ) )
operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
return_value = false ;
}
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
}
//remove the mountpoint..
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("remove temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
if ( ! rmdir( TEMP_MP .c_str() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
operationdetail .get_last_child() .add_child(
OperationDetail( Glib::strerror( errno ), STATUS_NONE ) ) ;
return_value = false ;
@ -177,24 +175,24 @@ bool jfs::Resize( const Partition & partition_new,
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
operationdetail .get_last_child() .add_child(
OperationDetail( Glib::strerror( errno ), STATUS_NONE ) ) ;
}
return return_value ;
}
bool jfs::Copy( const Glib::ustring & src_part_path,
bool jfs::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
return true ;
}
bool jfs::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool jfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
exit_status = execute_command( "jfs_fsck -f " + partition .get_path(), operation_details ) ;
exit_status = execute_command( "jfs_fsck -f " + partition .get_path(), operationdetail ) ;
return ( exit_status == 0 || exit_status == 1 ) ;
}

View file

@ -39,30 +39,39 @@ FS linux_swap::get_filesystem_support()
return fs ;
}
void linux_swap::Set_Used_Sectors( Partition & partition )
void linux_swap::set_used_sectors( Partition & partition )
{
}
bool linux_swap::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool linux_swap::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkswap " + new_partition .get_path(), operation_details ) ;
return ! execute_command( "mkswap " + new_partition .get_path(), operationdetail ) ;
}
bool linux_swap::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool linux_swap::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
return Create( partition_new, operation_details ) ;
operationdetail .add_child( OperationDetail(
String::ucompose( _("create new %1 filesystem"), Utils::get_filesystem_string( FS_LINUX_SWAP ) ) ) ) ;
if ( create( partition_new, operationdetail .get_last_child() ) )
{
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
return true ;
}
else
{
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
return false ;
}
}
bool linux_swap::Copy( const Glib::ustring & src_part_path,
bool linux_swap::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
return true ;
}
bool linux_swap::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool linux_swap::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
return true ;
}

View file

@ -54,7 +54,7 @@ FS ntfs::get_filesystem_support()
return fs ;
}
void ntfs::Set_Used_Sectors( Partition & partition )
void ntfs::set_used_sectors( Partition & partition )
{
if ( ! Utils::execute_command( "ntfscluster --force " + partition .get_path(), output, error, true ) )
{
@ -70,14 +70,12 @@ void ntfs::Set_Used_Sectors( Partition & partition )
partition .messages .push_back( error ) ;
}
bool ntfs::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool ntfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkntfs -Q -vv " + new_partition .get_path(), operation_details ) ;
return ! execute_command( "mkntfs -Q -vv " + new_partition .get_path(), operationdetail ) ;
}
bool ntfs::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool ntfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
bool return_value = false ;
Glib::ustring str_temp = "ntfsresize -P --force --force " + partition_new .get_path() ;
@ -90,43 +88,43 @@ bool ntfs::Resize( const Partition & partition_new,
}
//simulation..
operation_details .push_back( OperationDetail( _("run simulation") ) ) ;
operationdetail .add_child( OperationDetail( _("run simulation") ) ) ;
if ( ! execute_command( str_temp + " --no-action", operation_details .back() .sub_details ) )
if ( ! execute_command( str_temp + " --no-action", operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
//real resize
operation_details .push_back( OperationDetail( _("real resize") ) ) ;
operationdetail .add_child( OperationDetail( _("real resize") ) ) ;
if ( ! execute_command( str_temp, operation_details .back() .sub_details ) )
if ( ! execute_command( str_temp, operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
return_value = true ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
}
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
}
return return_value ;
}
bool ntfs::Copy( const Glib::ustring & src_part_path,
bool ntfs::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
return ! execute_command( "ntfsclone -f --overwrite " + dest_part_path + " " + src_part_path, operation_details ) ;
return ! execute_command( "ntfsclone -f --overwrite " + dest_part_path + " " + src_part_path, operationdetail ) ;
}
bool ntfs::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool ntfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
return ! execute_command( "ntfsresize -P -i -f -v " + partition .get_path(), operation_details ) ;
return ! execute_command( "ntfsresize -P -i -f -v " + partition .get_path(), operationdetail ) ;
}
} //GParted

View file

@ -50,7 +50,7 @@ FS reiser4::get_filesystem_support()
return fs ;
}
void reiser4::Set_Used_Sectors( Partition & partition )
void reiser4::set_used_sectors( Partition & partition )
{
if ( ! Utils::execute_command( "debugfs.reiser4 " + partition .get_path(), output, error, true ) )
{
@ -71,28 +71,26 @@ void reiser4::Set_Used_Sectors( Partition & partition )
partition .messages .push_back( error ) ;
}
bool reiser4::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool reiser4::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkfs.reiser4 --yes " + new_partition .get_path(), operation_details ) ;
return ! execute_command( "mkfs.reiser4 --yes " + new_partition .get_path(), operationdetail ) ;
}
bool reiser4::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool reiser4::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
return true ;
}
bool reiser4::Copy( const Glib::ustring & src_part_path,
bool reiser4::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
return true ;
}
bool reiser4::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool reiser4::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
return ! execute_command( "fsck.reiser4 --yes --fix " + partition .get_path(), operation_details ) ;
return ! execute_command( "fsck.reiser4 --yes --fix " + partition .get_path(), operationdetail ) ;
}
} //GParted

View file

@ -55,7 +55,7 @@ FS reiserfs::get_filesystem_support()
return fs ;
}
void reiserfs::Set_Used_Sectors( Partition & partition )
void reiserfs::set_used_sectors( Partition & partition )
{
if ( ! Utils::execute_command( "debugreiserfs " + partition .get_path(), output, error, true ) )
{
@ -76,14 +76,12 @@ void reiserfs::Set_Used_Sectors( Partition & partition )
partition .messages .push_back( error ) ;
}
bool reiserfs::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool reiserfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkreiserfs -f " + new_partition .get_path(), operation_details ) ;
return ! execute_command( "mkreiserfs -f " + new_partition .get_path(), operationdetail ) ;
}
bool reiserfs::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool reiserfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
Glib::ustring str_temp = "echo y | resize_reiserfs " + partition_new .get_path() ;
@ -94,21 +92,21 @@ bool reiserfs::Resize( const Partition & partition_new,
partition_new .get_length(), GParted::UNIT_BYTE ) ) -1, true ) ;
}
exit_status = execute_command( str_temp, operation_details ) ;
exit_status = execute_command( str_temp, operationdetail ) ;
return ( exit_status == 0 || exit_status == 256 ) ;
}
bool reiserfs::Copy( const Glib::ustring & src_part_path,
bool reiserfs::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
return true ;
}
bool reiserfs::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool reiserfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
exit_status = execute_command( "reiserfsck --y --fix-fixable " + partition .get_path(), operation_details ) ;
exit_status = execute_command( "reiserfsck --y --fix-fixable " + partition .get_path(), operationdetail ) ;
return ( exit_status == 0 || exit_status == 1 || exit_status == 256 ) ;
}

View file

@ -33,30 +33,28 @@ FS ufs::get_filesystem_support()
return fs ;
}
void ufs::Set_Used_Sectors( Partition & partition )
void ufs::set_used_sectors( Partition & partition )
{
}
bool ufs::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool ufs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return true ;
}
bool ufs::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool ufs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
return true ;
}
bool ufs::Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
bool ufs::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
OperationDetail & operationdetail )
{
return true ;
}
bool ufs::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool ufs::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
return true ;
}

View file

@ -70,7 +70,7 @@ FS xfs::get_filesystem_support()
return fs ;
}
void xfs::Set_Used_Sectors( Partition & partition )
void xfs::set_used_sectors( Partition & partition )
{
if ( ! Utils::execute_command(
"xfs_db -c 'sb 0' -c 'print blocksize' -c 'print fdblocks' -r " + partition .get_path(),
@ -95,80 +95,76 @@ void xfs::Set_Used_Sectors( Partition & partition )
partition .messages .push_back( error ) ;
}
bool xfs::Create( const Partition & new_partition, std::vector<OperationDetail> & operation_details )
bool xfs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return ! execute_command( "mkfs.xfs -f " + new_partition .get_path(), operation_details ) ;
return ! execute_command( "mkfs.xfs -f " + new_partition .get_path(), operationdetail ) ;
}
bool xfs::Resize( const Partition & partition_new,
std::vector<OperationDetail> & operation_details,
bool fill_partition )
bool xfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
{
bool return_value = false ;
Glib::ustring error ;
Glib::ustring TEMP_MP = Glib::get_tmp_dir() + "/gparted_tmp_xfs_mountpoint" ;
//create mountpoint...
operation_details .push_back(
OperationDetail( String::ucompose( _("create temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
operationdetail .add_child( OperationDetail( String::ucompose( _("create temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
if ( ! mkdir( TEMP_MP .c_str(), 0 ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
//mount partition
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("mount %1 on %2"), partition_new .get_path(), TEMP_MP ) ) ) ;
if ( ! execute_command( "mount -v -t xfs " + partition_new .get_path() + " " + TEMP_MP,
operation_details .back() .sub_details ) )
operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
//grow the mounted filesystem..
operation_details .push_back( OperationDetail( _("grow mounted filesystem") ) ) ;
operationdetail .add_child( OperationDetail( _("grow mounted filesystem") ) ) ;
if ( ! execute_command ( "xfs_growfs " + TEMP_MP,
operation_details .back() .sub_details ) )
if ( ! execute_command ( "xfs_growfs " + TEMP_MP, operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
return_value = true ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
}
//and unmount it...
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("unmount %1"), partition_new .get_path() ) ) ) ;
if ( ! execute_command( "umount -v " + partition_new .get_path(),
operation_details .back() .sub_details ) )
operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
return_value = false ;
}
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
}
//remove the mountpoint..
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("remove temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
if ( ! rmdir( TEMP_MP .c_str() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
operationdetail .get_last_child() .add_child(
OperationDetail( Glib::strerror( errno ), STATUS_NONE ) ) ;
return_value = false ;
@ -176,17 +172,16 @@ bool xfs::Resize( const Partition & partition_new,
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operation_details .back() .sub_details .push_back(
OperationDetail( Glib::strerror( errno ), STATUS_NONE ) ) ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
operationdetail .get_last_child() .add_child( OperationDetail( Glib::strerror( errno ), STATUS_NONE ) ) ;
}
return return_value ;
}
bool xfs::Copy( const Glib::ustring & src_part_path,
bool xfs::copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetail> & operation_details )
OperationDetail & operationdetail )
{
bool return_value = false ;
Glib::ustring error ;
@ -194,108 +189,112 @@ bool xfs::Copy( const Glib::ustring & src_part_path,
Glib::ustring DST = Glib::get_tmp_dir() + "/gparted_tmp_xfs_dest_mountpoint" ;
//create xfs filesystem on destination..
Partition partition( dest_part_path ) ;
if ( Create( partition, operation_details ) )
operationdetail .add_child( OperationDetail(
String::ucompose( _("create new %1 filesystem"), Utils::get_filesystem_string( FS_XFS ) ) ) ) ;
if ( create( Partition( dest_part_path ), operationdetail .get_last_child() ) )
{
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
//create source mountpoint...
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("create temporary mountpoint (%1)"), SRC ) ) ) ;
if ( ! mkdir( SRC .c_str(), 0 ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
//create destination mountpoint...
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("create temporary mountpoint (%1)"), DST ) ) ) ;
if ( ! mkdir( DST .c_str(), 0 ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
//mount source partition
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("mount %1 on %2"), src_part_path, SRC ) ) ) ;
if ( ! execute_command( "mount -v -t xfs -o noatime,ro " + src_part_path + " " + SRC,
operation_details .back() .sub_details ) )
operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
//mount destination partition
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("mount %1 on %2"), dest_part_path, DST ) ) ) ;
if ( ! execute_command( "mount -v -t xfs " + dest_part_path + " " + DST,
operation_details .back() .sub_details ) )
operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
//copy filesystem..
operation_details .push_back( OperationDetail( _("copy filesystem") ) ) ;
operationdetail .add_child( OperationDetail( _("copy filesystem") ) ) ;
if ( ! execute_command(
"xfsdump -J - " + SRC + " | xfsrestore -J - " + DST,
operation_details .back() .sub_details ) )
operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
return_value = true ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
}
//unmount destination partition
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("unmount %1"),
dest_part_path ) ) ) ;
if ( ! execute_command( "umount -v " + dest_part_path,
operation_details .back() .sub_details ) )
operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
return_value = false ;
}
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
}
//unmount source partition
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("unmount %1"), src_part_path ) ) ) ;
if ( ! execute_command( "umount -v " + src_part_path,
operation_details .back() .sub_details ) )
operationdetail .get_last_child() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
return_value = false ;
}
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
}
//remove destination mountpoint..
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("remove temporary mountpoint (%1)"), DST ) ) ) ;
if ( ! rmdir( DST .c_str() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
operationdetail .get_last_child() .add_child(
OperationDetail( Glib::strerror( errno ), STATUS_NONE ) ) ;
return_value = false ;
@ -303,22 +302,22 @@ bool xfs::Copy( const Glib::ustring & src_part_path,
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
operationdetail .get_last_child() .add_child(
OperationDetail( Glib::strerror( errno ), STATUS_NONE ) ) ;
}
//remove source mountpoint..
operation_details .push_back(
operationdetail .add_child(
OperationDetail( String::ucompose( _("remove temporary mountpoint (%1)"), SRC ) ) ) ;
if ( ! rmdir( SRC .c_str() ) )
{
operation_details .back() .status = STATUS_SUCCES ;
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
operationdetail .get_last_child() .add_child(
OperationDetail( Glib::strerror( errno ), STATUS_NONE ) ) ;
return_value = false ;
@ -326,18 +325,20 @@ bool xfs::Copy( const Glib::ustring & src_part_path,
}
else
{
operation_details .back() .status = STATUS_ERROR ;
operation_details .back() .sub_details .push_back(
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
operationdetail .get_last_child() .add_child(
OperationDetail( Glib::strerror( errno ), STATUS_NONE ) ) ;
}
}
else
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
return return_value ;
}
bool xfs::Check_Repair( const Partition & partition, std::vector<OperationDetail> & operation_details )
bool xfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
return ! execute_command( "xfs_repair -v " + partition .get_path(), operation_details ) ;
return ! execute_command( "xfs_repair -v " + partition .get_path(), operationdetail ) ;
}
} //GParted