* added detailed progressfeedback. It still needs some polishing, but
  is already far better then the old situation. And what's more, it's
  finally threadsafe :p
This commit is contained in:
Bart Hakvoort 2006-01-19 19:15:15 +00:00
parent 92e031e3e5
commit 97a9a5fa87
36 changed files with 1305 additions and 588 deletions

View File

@ -1,3 +1,9 @@
2006-01-19 Bart Hakvoort <hakvoort@cvs.gnome.org>
* added detailed progressfeedback. It still needs some polishing, but
is already far better then the old situation. And what's more, it's
finally threadsafe :p
2006-01-11 Bart Hakvoort <hakvoort@cvs.gnome.org> 2006-01-11 Bart Hakvoort <hakvoort@cvs.gnome.org>
* configure.in: bumped version to 0.1 * configure.in: bumped version to 0.1

View File

@ -20,15 +20,14 @@
#include "../include/i18n.h" #include "../include/i18n.h"
#include "../include/Utils.h" #include "../include/Utils.h"
#include "../include/Operation.h"
#include <gtkmm/dialog.h> #include <gtkmm/dialog.h>
#include <gtkmm/progressbar.h> #include <gtkmm/progressbar.h>
#include <gtkmm/stock.h> #include <gtkmm/treeview.h>
#include <gtkmm/label.h> #include <gtkmm/treestore.h>
#include <gtkmm/togglebutton.h>
#include <gtkmm/textview.h>
#include <gtkmm/textbuffer.h>
#include <gtkmm/scrolledwindow.h> #include <gtkmm/scrolledwindow.h>
#include <gtkmm/expander.h>
namespace GParted namespace GParted
{ {
@ -36,30 +35,52 @@ namespace GParted
class Dialog_Progress : public Gtk::Dialog class Dialog_Progress : public Gtk::Dialog
{ {
public: public:
Dialog_Progress( int count_operations, Glib::RefPtr<Gtk::TextBuffer> textbuffer ); Dialog_Progress( const std::vector<Operation> & operations ) ;
~Dialog_Progress( ); ~Dialog_Progress();
void Set_Operation( ); sigc::signal< bool, Operation & > signal_apply_operation ;
Glib::ustring current_operation;
int TIME_LEFT ;
private: private:
bool Show_Progress( ) ; void update_operation_details( const Gtk::TreeRow & treerow, const OperationDetails & operation_details ) ;
bool Pulse( ) { progressbar_current .pulse( ) ; return true ; } void on_signal_show() ;
void tglbtn_details_toggled( ) ; void thread_apply_operation( Operation * operation ) ;
Gtk::Label label_current ; Gtk::Label label_current ;
Gtk::ProgressBar progressbar_all, progressbar_current ; Gtk::ProgressBar progressbar_all, progressbar_current ;
Gtk::ToggleButton tglbtn_details ; Gtk::TreeView treeview_operations ;
Gtk::TextView textview_details ; Gtk::TreeRow treerow ;
Gtk::ScrolledWindow scrolledwindow ; Gtk::ScrolledWindow scrolledwindow ;
Gtk::Expander expander_details ;
void signal_textbuffer_insert( const Gtk::TextBuffer::iterator & iter, const Glib::ustring & text, int ) ; Glib::RefPtr<Gdk::Pixbuf> icon_execute ;
Glib::RefPtr<Gdk::Pixbuf> icon_succes ;
Glib::RefPtr<Gdk::Pixbuf> icon_error ;
Glib::RefPtr<Gtk::TreeStore> treestore_operations;
double fraction, fraction_current; struct treeview_operations_Columns : public Gtk::TreeModelColumnRecord
int count_operations, current_operation_number; {
sigc::connection conn ; Gtk::TreeModelColumn<Glib::ustring> operation_description;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > operation_icon;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > status_icon;
Gtk::TreeModelColumn<OperationDetails::Status> hidden_status ;
treeview_operations_Columns()
{
add( operation_description );
add( operation_icon );
add( status_icon ) ;
add( hidden_status ) ;
}
};
treeview_operations_Columns treeview_operations_columns;
std::vector<Operation> operations ;
bool pulse, succes ;
Glib::Thread *thread ;
double fraction ;
unsigned int t ;
Glib::ustring str_temp ;
}; };
}//GParted }//GParted

View File

@ -19,11 +19,8 @@
#ifndef DEFINE_FILESYSTEM #ifndef DEFINE_FILESYSTEM
#define DEFINE_FILESYSTEM #define DEFINE_FILESYSTEM
#include "../include/Partition.h" #include "../include/Operation.h"
#include <gtkmm/textbuffer.h>
#include <parted/parted.h>
#include <fstream> #include <fstream>
#include <sys/stat.h> #include <sys/stat.h>
@ -38,28 +35,29 @@ public:
virtual FS get_filesystem_support() = 0 ; virtual FS get_filesystem_support() = 0 ;
virtual void Set_Used_Sectors( Partition & partition ) = 0 ; virtual void Set_Used_Sectors( Partition & partition ) = 0 ;
virtual bool Create( const Partition & new_partition ) = 0 ; virtual bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) = 0 ;
virtual bool Resize( const Partition & partition_new, bool fill_partition = false ) = 0 ; virtual bool Resize( const Partition & partition_new,
virtual bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) = 0 ; std::vector<OperationDetails> & operation_details,
virtual bool Check_Repair( const Partition & partition ) = 0 ; bool fill_partition = false ) = 0 ;
virtual int get_estimated_time( long MB_to_Consider ) = 0 ; virtual bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
Glib::RefPtr<Gtk::TextBuffer> textbuffer ; std::vector<OperationDetails> & operation_details ) = 0 ;
virtual bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) = 0 ;
long cylinder_size ; //see GParted_Core::Resize() long cylinder_size ; //see GParted_Core::Resize()
protected: protected:
int Execute_Command( Glib::ustring command ) ; int Execute_Command( Glib::ustring command ) ;
int execute_command( std::vector<std::string> argv, std::vector<OperationDetails> & operation_details ) ;
//those are used in several Set_Used_Sectors().. //those are used in several Set_Used_Sectors()..
std::vector<std::string> argv, envp ; std::vector<std::string> argv, envp ;
std::string output ; std::string output, error ;
Sector N, S ; Sector N, S ;
unsigned int index ; unsigned int index ;
int exit_status ;
private: private:
void Update_Textview() ;
Glib::ustring cmd_output ; Glib::ustring cmd_output ;
}; };

View File

@ -32,6 +32,7 @@
#include "../include/hfsplus.h" #include "../include/hfsplus.h"
#include "../include/reiser4.h" #include "../include/reiser4.h"
#include <parted/parted.h>
#include <vector> #include <vector>
#include <fstream> #include <fstream>
@ -45,21 +46,25 @@ public:
void find_supported_filesystems( ) ; void find_supported_filesystems( ) ;
void get_devices( std::vector<Device> & devices ) ; void get_devices( std::vector<Device> & devices ) ;
int get_estimated_time( const Operation & operation ) ; bool apply_operation_to_disk( Operation & operation );
void Apply_Operation_To_Disk( Operation & operation );
bool Create( const Device & device, Partition & new_partition ) ; bool create( const Device & device,
bool format( const Partition & partition ) ; Partition & new_partition,
bool Delete( const Partition & partition ) ; std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Device & device, const Partition & partition_old, const Partition & partition_new ) ; bool format( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
bool Copy( const Glib::ustring & src_part_path, Partition & partition_dest ) ; bool Delete( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
bool resize( const Device & device,
const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetails> & operation_detail ) ;
bool copy( const Glib::ustring & src_part_path,
Partition & partition_dest,
std::vector<OperationDetails> & operation_details ) ;
bool Set_Disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ; bool Set_Disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ;
const std::vector<FS> & get_filesystems( ) const ; const std::vector<FS> & get_filesystems( ) const ;
const FS & get_fs( GParted::FILESYSTEM filesystem ) const ; const FS & get_fs( GParted::FILESYSTEM filesystem ) const ;
Glib::RefPtr<Gtk::TextBuffer> get_textbuffer( ) ;
std::vector<Glib::ustring> get_disklabeltypes( ) ; std::vector<Glib::ustring> get_disklabeltypes( ) ;
private: private:
@ -73,13 +78,20 @@ private:
Glib::ustring get_short_path( const Glib::ustring & real_path ) ; Glib::ustring get_short_path( const Glib::ustring & real_path ) ;
void LP_Set_Used_Sectors( Partition & partition ); void LP_Set_Used_Sectors( Partition & partition );
Glib::ustring Get_Flags( ) ; Glib::ustring Get_Flags( ) ;
int Create_Empty_Partition( Partition & new_partition, bool copy = false ) ; int create_empty_partition( Partition & new_partition,
bool Resize_Container_Partition( const Partition & partition_old, const Partition & partition_new, bool fixed_start ) ; std::vector<OperationDetails> & operation_details,
bool Resize_Normal_Using_Libparted( const Partition & partition_old, const Partition & partition_new ) ; bool copy = false ) ;
bool resize_container_partition( const Partition & partition_old,
const Partition & partition_new,
bool fixed_start,
std::vector<OperationDetails> & operation_details ) ;
bool resize_normal_using_libparted( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetails> & operation_detail ) ;
void Show_Error( Glib::ustring message ) ;
void set_proper_filesystem( const FILESYSTEM & filesystem ) ; void set_proper_filesystem( const FILESYSTEM & filesystem ) ;
bool set_partition_type( const Partition & partition ) ; bool set_partition_type( const Partition & partition,
std::vector<OperationDetails> & operation_details ) ;
bool wait_for_node( const Glib::ustring & node ) ; bool wait_for_node( const Glib::ustring & node ) ;
bool erase_filesystem_signatures( const Partition & partition ) ; bool erase_filesystem_signatures( const Partition & partition ) ;
@ -88,8 +100,6 @@ private:
void close_device_and_disk( ) ; void close_device_and_disk( ) ;
bool commit( ) ; bool commit( ) ;
Glib::RefPtr<Gtk::TextBuffer> textbuffer;
std::vector<FS> FILESYSTEMS ; std::vector<FS> FILESYSTEMS ;
FileSystem * p_filesystem ; FileSystem * p_filesystem ;
std::vector <PedPartitionFlag> flags; std::vector <PedPartitionFlag> flags;

View File

@ -18,11 +18,7 @@
#ifndef OPERATION #ifndef OPERATION
#define OPERATION #define OPERATION
#include "../include/Partition.h"
#include "../include/Device.h" #include "../include/Device.h"
#include "../include/i18n.h"
#include <gtkmm/messagedialog.h>
namespace GParted namespace GParted
{ {
@ -35,10 +31,37 @@ enum OperationType {
COPY = 4 COPY = 4
}; };
struct OperationDetails
{
enum Status {
NONE = -1,
EXECUTE = 0,
SUCCES = 1,
ERROR = 2
};
OperationDetails()
{
status = EXECUTE ;
}
OperationDetails( const Glib::ustring & description, Status status = EXECUTE )
{
this ->description = description ;
this ->status = status ;
}
Glib::ustring description ;
Status status ;
std::vector<OperationDetails> sub_details ;
};
class Operation class Operation
{ {
public: public:
Operation() ;
Operation( const Device & device, const Partition &, const Partition &, OperationType ); Operation( const Device & device, const Partition &, const Partition &, OperationType );
//this one can be a little confusing, it *DOES NOT* change any visual representation. It only applies the operation to the list with partitions. //this one can be a little confusing, it *DOES NOT* change any visual representation. It only applies the operation to the list with partitions.
@ -48,10 +71,13 @@ public:
//public variables //public variables
Device device ; Device device ;
OperationType operationtype; OperationType operationtype;
Glib::RefPtr<Gdk::Pixbuf> operation_icon ;
Partition partition_original; //the original situation Partition partition_original; //the original situation
Partition partition_new; //the new situation ( can be an whole new partition or simply the old one with a new size or.... ) Partition partition_new; //the new situation ( can be an whole new partition or simply the old one with a new size or.... )
Glib::ustring str_operation ; Glib::ustring str_operation ;
Glib::ustring copied_partition_path ; //for copy operation.. Glib::ustring copied_partition_path ; //for copy operation..
OperationDetails operation_details ;
private: private:
void Insert_Unallocated( std::vector<Partition> & partitions, Sector start, Sector end, bool inside_extended ); void Insert_Unallocated( std::vector<Partition> & partitions, Sector start, Sector end, bool inside_extended );

View File

@ -68,7 +68,7 @@ private:
void Fill_Label_Device_Info( bool clear = false ); void Fill_Label_Device_Info( bool clear = false );
//overridden signalhandler //overridden signalhandler
virtual bool on_delete_event( GdkEventAny* ) ; bool on_delete_event( GdkEventAny* ) ;
void Add_Operation( OperationType, const Partition & ); void Add_Operation( OperationType, const Partition & );
void Refresh_Visual( ); void Refresh_Visual( );
@ -139,7 +139,7 @@ private:
void on_partition_activated() ; void on_partition_activated() ;
void on_partition_popup_menu( unsigned int button, unsigned int time ) ; void on_partition_popup_menu( unsigned int button, unsigned int time ) ;
bool max_amount_prim_reached( ) ; bool max_amount_prim_reached() ;
void activate_resize(); void activate_resize();
void activate_copy(); void activate_copy();
@ -152,9 +152,8 @@ private:
void activate_disable_swap() ; void activate_disable_swap() ;
void activate_disklabel() ; void activate_disklabel() ;
void activate_undo( ); void activate_undo();
void activate_apply( ); void activate_apply();
void apply_operations_thread( );
//private variables //private variables
unsigned int current_device ; unsigned int current_device ;
@ -210,13 +209,11 @@ private:
struct treeview_operations_Columns : public Gtk::TreeModelColumnRecord struct treeview_operations_Columns : public Gtk::TreeModelColumnRecord
{ {
Gtk::TreeModelColumn<int> operation_number;
Gtk::TreeModelColumn<Glib::ustring> operation_description; Gtk::TreeModelColumn<Glib::ustring> operation_description;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > operation_icon; Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > operation_icon;
treeview_operations_Columns() treeview_operations_Columns()
{ {
add( operation_number );
add( operation_description ); add( operation_description );
add( operation_icon ); add( operation_icon );
} }
@ -235,11 +232,10 @@ private:
std::vector<Gtk::Label *> device_info ; std::vector<Gtk::Label *> device_info ;
//stuff for progress overview and pulsebar //stuff for progress overview and pulsebar
Dialog_Progress *dialog_progress;
Glib::Thread *thread ; Glib::Thread *thread ;
Glib::Dispatcher dispatcher; Glib::Dispatcher dispatcher;
sigc::connection conn ; sigc::connection conn ;
bool apply, pulse ; bool pulse ;
}; };
} //GParted } //GParted

View File

@ -29,11 +29,14 @@ class ext2 : public FileSystem
public: public:
FS get_filesystem_support( ) ; FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ; void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition ) ; bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ; bool Resize( const Partition & partition_new,
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; std::vector<OperationDetails> & operation_details,
bool Check_Repair( const Partition & partition ) ; bool fill_partition = false ) ;
int get_estimated_time( long MB_to_Consider ) ; bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
}; };
} //GParted } //GParted

View File

@ -29,11 +29,14 @@ class ext3 : public FileSystem
public: public:
FS get_filesystem_support( ) ; FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ; void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition ) ; bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ; bool Resize( const Partition & partition_new,
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; std::vector<OperationDetails> & operation_details,
bool Check_Repair( const Partition & partition ) ; bool fill_partition = false ) ;
int get_estimated_time( long MB_to_Consider ) ; bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
}; };

View File

@ -29,12 +29,14 @@ class fat16 : public FileSystem
public: public:
FS get_filesystem_support( ) ; FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ; void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition ) ; bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ; bool Resize( const Partition & partition_new,
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; std::vector<OperationDetails> & operation_details,
bool Check_Repair( const Partition & partition ) ; bool fill_partition = false ) ;
int get_estimated_time( long MB_to_Consider ) ; bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
}; };
} //GParted } //GParted

View File

@ -29,11 +29,14 @@ class fat32 : public FileSystem
public: public:
FS get_filesystem_support( ); FS get_filesystem_support( );
void Set_Used_Sectors( Partition & partition ) ; void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition ) ; bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ; bool Resize( const Partition & partition_new,
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; std::vector<OperationDetails> & operation_details,
bool Check_Repair( const Partition & partition ) ; bool fill_partition = false ) ;
int get_estimated_time( long MB_to_Consider ) ; bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
}; };
} //GParted } //GParted

View File

@ -29,11 +29,14 @@ class hfs : public FileSystem
public: public:
FS get_filesystem_support( ) ; FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ; void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition ) ; bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ; bool Resize( const Partition & partition_new,
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; std::vector<OperationDetails> & operation_details,
bool Check_Repair( const Partition & partition ) ; bool fill_partition = false ) ;
int get_estimated_time( long MB_to_Consider ) ; bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
}; };
} //GParted } //GParted

View File

@ -29,11 +29,14 @@ class hfsplus : public FileSystem
public: public:
FS get_filesystem_support( ) ; FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ; void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition ) ; bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ; bool Resize( const Partition & partition_new,
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; std::vector<OperationDetails> & operation_details,
bool Check_Repair( const Partition & partition ) ; bool fill_partition = false ) ;
int get_estimated_time( long MB_to_Consider ) ; bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
}; };
} //GParted } //GParted

View File

@ -29,11 +29,14 @@ class jfs : public FileSystem
public: public:
FS get_filesystem_support( ) ; FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ; void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition ) ; bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ; bool Resize( const Partition & partition_new,
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; std::vector<OperationDetails> & operation_details,
bool Check_Repair( const Partition & partition ) ; bool fill_partition = false ) ;
int get_estimated_time( long MB_to_Consider ) ; bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
}; };
} //GParted } //GParted

View File

@ -29,11 +29,14 @@ class linux_swap : public FileSystem
public: public:
FS get_filesystem_support( ) ; FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ; void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition ) ; bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ; bool Resize( const Partition & partition_new,
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; std::vector<OperationDetails> & operation_details,
bool Check_Repair( const Partition & partition ) ; bool fill_partition = false ) ;
int get_estimated_time( long MB_to_Consider ) ; bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
}; };
} //GParted } //GParted

View File

@ -29,11 +29,14 @@ class ntfs : public FileSystem
public: public:
FS get_filesystem_support( ) ; FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ; void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition ) ; bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ; bool Resize( const Partition & partition_new,
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; std::vector<OperationDetails> & operation_details,
bool Check_Repair( const Partition & partition ) ; bool fill_partition = false ) ;
int get_estimated_time( long MB_to_Consider ) ; bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
}; };
} //GParted } //GParted

View File

@ -29,11 +29,14 @@ class reiser4 : public FileSystem
public: public:
FS get_filesystem_support( ) ; FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ; void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition ) ; bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ; bool Resize( const Partition & partition_new,
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; std::vector<OperationDetails> & operation_details,
bool Check_Repair( const Partition & partition ) ; bool fill_partition = false ) ;
int get_estimated_time( long MB_to_Consider ) ; bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
}; };
} //GParted } //GParted

View File

@ -29,11 +29,14 @@ class reiserfs : public FileSystem
public: public:
FS get_filesystem_support( ) ; FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ; void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition ) ; bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ; bool Resize( const Partition & partition_new,
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; std::vector<OperationDetails> & operation_details,
bool Check_Repair( const Partition & partition ) ; bool fill_partition = false ) ;
int get_estimated_time( long MB_to_Consider ) ; bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
}; };
} //GParted } //GParted

View File

@ -27,13 +27,16 @@ namespace GParted
class xfs : public FileSystem class xfs : public FileSystem
{ {
public: public:
FS get_filesystem_support( ) ; FS get_filesystem_support() ;
void Set_Used_Sectors( Partition & partition ) ; void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Partition & new_partition ) ; bool Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ; bool Resize( const Partition & partition_new,
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ; std::vector<OperationDetails> & operation_details,
bool Check_Repair( const Partition & partition ) ; bool fill_partition = false ) ;
int get_estimated_time( long MB_to_Consider ) ; bool Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details ) ;
bool Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
}; };
} //GParted } //GParted

View File

@ -16,123 +16,225 @@
*/ */
#include "../include/Dialog_Progress.h" #include "../include/Dialog_Progress.h"
#include <iostream>
#include <gtkmm/stock.h>
#include <gtkmm/main.h>
#include <gtkmm/messagedialog.h>
namespace GParted namespace GParted
{ {
Dialog_Progress::Dialog_Progress( int count_operations, Glib::RefPtr<Gtk::TextBuffer> textbuffer ) Dialog_Progress::Dialog_Progress( const std::vector<Operation> & operations )
{ {
this ->set_resizable( false ) ;
this ->set_has_separator( false ) ; this ->set_has_separator( false ) ;
this ->set_title( _("Applying pending operations") ) ; this ->set_title( _("Applying pending operations") ) ;
this ->operations = operations ;
this ->count_operations = count_operations ; succes = true ;
current_operation_number = 0 ;
fraction = 1.00 / count_operations ; fraction = 1.00 / operations .size() ;
Glib::ustring str_temp = "<span weight=\"bold\" size=\"larger\">" ; Glib::ustring str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += _( "Applying pending operations" ) ; str_temp += _("Applying pending operations") ;
str_temp += "</span>\n\n" ; str_temp += "</span>\n\n" ;
str_temp += _("Applying all listed operations.") ; str_temp += _("Applying all listed operations.") ;
str_temp += "\n"; str_temp += "\n";
str_temp += _("Clicking Cancel will prevent the next operations from being applied.") ; str_temp += _("Depending on the amount and type of operations this might take a long time.") ;
str_temp += "\n"; str_temp += "\n";
this ->get_vbox( ) ->pack_start( * Utils::mk_label( str_temp ), Gtk::PACK_SHRINK ); this ->get_vbox() ->pack_start( * Utils::mk_label( str_temp ), Gtk::PACK_SHRINK );
this ->get_vbox() ->pack_start( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("Current Operation:") ) + "</b>" ), Gtk::PACK_SHRINK );
progressbar_current .set_pulse_step( 0.01 ) ; progressbar_current .set_pulse_step( 0.01 ) ;
progressbar_current .set_size_request( 500, -1 ) ; this->get_vbox() ->pack_start( progressbar_current, Gtk::PACK_SHRINK );
this->get_vbox( ) ->pack_start( progressbar_current, Gtk::PACK_SHRINK );
label_current .set_alignment( Gtk::ALIGN_LEFT ); label_current .set_alignment( Gtk::ALIGN_LEFT );
this ->get_vbox( ) ->pack_start( label_current, Gtk::PACK_SHRINK ); this ->get_vbox() ->pack_start( label_current, Gtk::PACK_SHRINK );
textview_details .set_sensitive( false ) ; this ->get_vbox() ->pack_start( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("Completed Operations:") ) + "</b>" ), Gtk::PACK_SHRINK );
textview_details .set_size_request( -1, 100 ) ; progressbar_all .set_size_request( 500, -1 ) ;
textview_details .set_wrap_mode( Gtk::WRAP_WORD ) ; this ->get_vbox() ->pack_start( progressbar_all, Gtk::PACK_SHRINK );
//create some icons here, instead of recreating them every time
icon_execute = render_icon( Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_LARGE_TOOLBAR ) ;
icon_succes = render_icon( Gtk::Stock::APPLY, Gtk::ICON_SIZE_LARGE_TOOLBAR ) ;
icon_error = render_icon( Gtk::Stock::DIALOG_ERROR, Gtk::ICON_SIZE_LARGE_TOOLBAR ) ;
treestore_operations = Gtk::TreeStore::create( treeview_operations_columns );
treeview_operations .set_model( treestore_operations );
treeview_operations .set_headers_visible( false );
treeview_operations .append_column( "", treeview_operations_columns .operation_icon );
treeview_operations .append_column( "", treeview_operations_columns .operation_description );
treeview_operations .append_column( "", treeview_operations_columns .status_icon );
treeview_operations .set_size_request( -1, 250 ) ;
treeview_operations .set_rules_hint( true ) ;
//fill 'er up
for ( unsigned int t = 0 ; t < operations .size() ; t++ )
{
treerow = *( treestore_operations ->append() );
treerow[ treeview_operations_columns .operation_icon ] = operations[ t ] .operation_icon ;
treerow[ treeview_operations_columns .operation_description ] = operations[ t ] .str_operation ;
this ->operations[ t ] .operation_details .description = operations[ t ] .str_operation ;
}
treeview_operations .get_column( 1 ) ->set_expand( true ) ;
textbuffer ->signal_insert( ) .connect( sigc::mem_fun( this, &Dialog_Progress::signal_textbuffer_insert ) ) ;
textview_details .set_buffer( textbuffer ) ;
scrolledwindow .set_shadow_type( Gtk::SHADOW_ETCHED_IN ) ; scrolledwindow .set_shadow_type( Gtk::SHADOW_ETCHED_IN ) ;
scrolledwindow .set_policy( Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC ) ; scrolledwindow .set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ) ;
scrolledwindow .add( textview_details ) ; scrolledwindow .add( treeview_operations ) ;
expander_details .set_label( "<b>" + static_cast<Glib::ustring>( _("Details") ) + "</b>" ) ;
expander_details .set_use_markup( true ) ;
expander_details .add( scrolledwindow ) ;
this ->get_vbox( ) ->pack_start( scrolledwindow, Gtk::PACK_SHRINK ); this ->get_vbox() ->pack_start( expander_details, Gtk::PACK_EXPAND_WIDGET );
this ->get_vbox( ) ->pack_start( * Utils::mk_label( "<b>\n" + static_cast<Glib::ustring>( _( "Completed Operations" ) ) + ":</b>" ), Gtk::PACK_SHRINK ); this ->get_vbox() ->set_spacing( 5 ) ;
this ->get_vbox( ) ->pack_start( progressbar_all, Gtk::PACK_SHRINK );
this ->get_vbox( ) ->set_spacing( 5 ) ; this ->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_NONE ) ;
tglbtn_details .set_label( _("Details") ) ; this ->signal_show() .connect( sigc::mem_fun(*this, &Dialog_Progress::on_signal_show) );
tglbtn_details .signal_toggled( ) .connect( sigc::mem_fun( this, &Dialog_Progress::tglbtn_details_toggled ) ) ; this ->show_all_children() ;
this ->get_action_area( ) ->set_layout( Gtk::BUTTONBOX_EDGE ) ;
this ->get_action_area( ) ->pack_start( tglbtn_details ) ;
this ->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
this ->show_all_children( ) ;
scrolledwindow .hide( ) ;
} }
void Dialog_Progress::Set_Operation( ) void Dialog_Progress::update_operation_details( const Gtk::TreeRow & treerow,
const OperationDetails & operation_details )
{ {
//all operations Gtk::TreeRow treerow_child ;
if ( current_operation_number && (progressbar_all .get_fraction( ) + fraction) <= 1.0 )
progressbar_all .set_fraction( progressbar_all .get_fraction( ) + fraction );
progressbar_all .set_text( String::ucompose( _("%1 of %2 operations completed"), current_operation_number++, count_operations ) ) ; //append new rows (if any)
for ( unsigned int t = treerow .children() .size() ; t < operation_details .sub_details .size() ; t++ )
//new operation
conn .disconnect( ) ;
label_current .set_markup( "<i>" + current_operation + "</i>" ) ;
progressbar_current .set_fraction( 0 );
progressbar_current .set_text( "initializing..." );
if ( TIME_LEFT > 0 )
{ {
fraction_current = 1.00 / TIME_LEFT ; treerow_child = *( treestore_operations ->append( treerow .children() ) ) ;
conn = Glib::signal_timeout( ) .connect( sigc::mem_fun( *this, &Dialog_Progress::Show_Progress ), 1000 );
treerow_child[ treeview_operations_columns .operation_description ] =
operation_details .sub_details[ t ] .description ;
treerow_child[ treeview_operations_columns .hidden_status ] = OperationDetails::NONE ;
} }
else
conn = Glib::signal_timeout( ) .connect( sigc::mem_fun( *this, &Dialog_Progress::Pulse ), 10 );
}
bool Dialog_Progress::Show_Progress( ) for ( unsigned int t = 0 ; t < operation_details .sub_details .size() ; t++ )
{
if ( (progressbar_current .get_fraction( ) + fraction_current) <= 1.0 )
{ {
progressbar_current .set_fraction( progressbar_current .get_fraction( ) + fraction_current ); treerow_child = treerow .children()[ t ] ;
if ( TIME_LEFT > 59 && TIME_LEFT < 120 ) if ( operation_details .sub_details[ t ] .status != treerow_child[ treeview_operations_columns .hidden_status ] )
progressbar_current .set_text( String::ucompose( _("about %1 minute and %2 seconds left"), TIME_LEFT/60, TIME_LEFT % 60 ) ) ; {
else treerow_child[ treeview_operations_columns .hidden_status ] =
progressbar_current .set_text( String::ucompose( _("about %1 minutes and %2 seconds left"), TIME_LEFT/60, TIME_LEFT % 60 ) ) ; operation_details .sub_details[ t ] .status ;
switch ( operation_details .sub_details[ t ] .status )
{
case OperationDetails::EXECUTE:
treerow_child[ treeview_operations_columns .status_icon ] = icon_execute ;
break ;
case OperationDetails::SUCCES:
treerow_child[ treeview_operations_columns .status_icon ] = icon_succes ;
break ;
case OperationDetails::ERROR:
treerow_child[ treeview_operations_columns .status_icon ] = icon_error ;
break ;
default :
//plain, old-fashioned paranoia ;)
treerow_child[ treeview_operations_columns .hidden_status ] =
OperationDetails::NONE ;
break ;
}
}
TIME_LEFT-- ; update_operation_details( treerow_child, operation_details .sub_details[ t ] ) ;
} }
}
void Dialog_Progress::on_signal_show()
{
for ( t = 0 ; t < operations .size() && succes ; t++ )
{
label_current .set_markup( "<i>" + operations[ t ] .str_operation + "</i>" ) ;
return true ; progressbar_all .set_text( String::ucompose( _("%1 of %2 operations completed"), t, operations .size() ) ) ;
progressbar_all .set_fraction( fraction * t ) ;
static_cast<Gtk::TreeRow>( treestore_operations ->children()[ t ] )
[ treeview_operations_columns .status_icon ] = icon_execute ;
treeview_operations .set_cursor( static_cast<Gtk::TreePath>( treestore_operations ->children()[ t ] ) ) ;
pulse = true ;
thread = Glib::Thread::create( sigc::bind<Operation *>(
sigc::mem_fun( *this, &Dialog_Progress::thread_apply_operation ), &( operations[ t ] ) ), true );
treerow = treestore_operations ->children()[ t ] ;
while ( pulse )
{
update_operation_details( treerow, operations[ t ] .operation_details ) ;
progressbar_current .pulse() ;
while ( Gtk::Main::events_pending() )
Gtk::Main::iteration();
usleep( 10000 ) ;
}
thread ->join() ;
//final updates for this operation
update_operation_details( treerow, operations[ t ] .operation_details ) ;
static_cast<Gtk::TreeRow>( treestore_operations ->children()[ t ] )
[ treeview_operations_columns .status_icon ] = succes ? icon_succes : icon_error ;
}
//replace 'cancel' with 'close'
std::vector<Gtk::Widget *> children = this ->get_action_area() ->get_children() ;
this ->get_action_area() ->remove( * children .back() ) ;
this ->add_button( Gtk::Stock::CLOSE, Gtk::RESPONSE_OK );
//hide 'current operation' stuff
children = this ->get_vbox() ->get_children() ;
children[ 1 ] ->hide() ;
progressbar_current .hide() ;
label_current .hide() ;
//deal with succes/error...
if ( succes )
{
progressbar_all .set_text( _("All operations succesfully completed") ) ;
progressbar_all .set_fraction( 1.0 ) ;
}
else
{
progressbar_all .set_text( _("Not all operations were succesfully completed") ) ;
expander_details .set_expanded( true ) ;
Gtk::MessageDialog dialog( *this,
_("An error occurred while applying the operations"),
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK,
true ) ;
str_temp = _("The following operation could not be applied to disk:") ;
str_temp += "\n<i>" ;
str_temp += label_current .get_text() ;
str_temp += "</i>\n\n" ;
str_temp += _("See the details for more information") ;
dialog .set_secondary_text( str_temp, true ) ;
dialog .run() ;
}
} }
void Dialog_Progress::tglbtn_details_toggled( ) void Dialog_Progress::thread_apply_operation( Operation * operation )
{ {
if ( tglbtn_details .get_active( ) ) succes = signal_apply_operation .emit( *operation ) ;
scrolledwindow .show( ) ;
else
scrolledwindow .hide( ) ;
}
void Dialog_Progress::signal_textbuffer_insert( const Gtk::TextBuffer::iterator & iter, const Glib::ustring & text, int ) pulse = false ;
{
Gtk::TextBuffer::iterator temp = iter ;
textview_details .scroll_to( temp, 0 ) ;
} }
Dialog_Progress::~Dialog_Progress() Dialog_Progress::~Dialog_Progress()
{ {
conn .disconnect( ) ;
} }

View File

@ -21,21 +21,18 @@
namespace GParted namespace GParted
{ {
FileSystem::FileSystem( ) FileSystem::FileSystem()
{ {
cylinder_size = 0 ; cylinder_size = 0 ;
} }
int FileSystem::Execute_Command( Glib::ustring command ) int FileSystem::Execute_Command( Glib::ustring command )
{ {
Glib::Dispatcher dispatcher;
sigc::connection conn = dispatcher .connect( sigc::mem_fun(*this, &FileSystem::Update_Textview) );
//stderr to stdout //stderr to stdout
//command += " 2>&1" ; //command += " 2>&1" ;
std::cout << command << std::endl ; std::cout << command << std::endl ;
cmd_output = command + "\n\n" ; cmd_output = command + "\n\n" ;
dispatcher ( ) ;
char c_buf[ 512 ] ; char c_buf[ 512 ] ;
FILE *f = popen( command .c_str( ), "r" ) ; FILE *f = popen( command .c_str( ), "r" ) ;
@ -44,20 +41,48 @@ int FileSystem::Execute_Command( Glib::ustring command )
{ {
//output = Glib::locale_to_utf8( c_buf ) ; //output = Glib::locale_to_utf8( c_buf ) ;
//std::cout << output << std::endl ; //std::cout << output << std::endl ;
//dispatcher ( ) ;disabled for the moment. Hier moet ik nog eens fris naar kijken. (anjuta had zo'n ingebouwde terminal, hoe deed die dat?? !!!
} }
cmd_output = "" ; cmd_output = "" ;
dispatcher( ) ;
return pclose( f ) ; return pclose( f ) ;
} }
void FileSystem::Update_Textview( ) int FileSystem::execute_command( std::vector<std::string> argv, std::vector<OperationDetails> & operation_details )
{ {
//std::cout << output << std::endl; Glib::ustring temp ;
textbuffer ->set_text( cmd_output ) ; for ( unsigned int t = 0 ; t < argv .size() ; t++ )
//textbuffer ->insert( textbuffer ->end( ), output ) ; temp += argv[ t ] + " " ;
operation_details .push_back( OperationDetails( temp, OperationDetails::NONE ) ) ;
envp .clear() ;
envp .push_back( "LC_ALL=C" ) ;
try
{
Glib::spawn_sync( ".",
argv,
envp,
Glib::SPAWN_SEARCH_PATH,
sigc::slot< void >(),
&output,
&error,
&exit_status ) ;
}
catch ( Glib::Exception & e )
{
std::cout << e .what() << std::endl ;
return -1 ;
}
if ( ! output .empty() )
operation_details .back() .sub_details .push_back( OperationDetails( output, OperationDetails::NONE ) ) ;
if ( ! error .empty() )
operation_details .back() .sub_details .push_back( OperationDetails( error, OperationDetails::NONE ) ) ;
return exit_status ;
} }
} //GParted } //GParted

View File

@ -11,7 +11,6 @@ GParted_Core::GParted_Core( )
lp_disk = NULL ; lp_disk = NULL ;
lp_partition = NULL ; lp_partition = NULL ;
p_filesystem = NULL ; p_filesystem = NULL ;
textbuffer = Gtk::TextBuffer::create( ) ;
//get valid flags ... //get valid flags ...
for ( PedPartitionFlag flag = ped_partition_flag_next( (PedPartitionFlag) NULL ) ; flag ; flag = ped_partition_flag_next( flag ) ) for ( PedPartitionFlag flag = ped_partition_flag_next( (PedPartitionFlag) NULL ) ; flag ; flag = ped_partition_flag_next( flag ) )
@ -469,72 +468,45 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path, std::v
} }
} }
int GParted_Core::get_estimated_time( const Operation & operation ) bool GParted_Core::apply_operation_to_disk( Operation & operation )
{
switch ( operation .operationtype )
{
case GParted::DELETE:
return 2 ; //i guess it'll never take more then 2 secs to delete a partition ;)
case GParted::CREATE:
case GParted::FORMAT:
set_proper_filesystem( operation .partition_new .filesystem ) ;
if ( p_filesystem )
return p_filesystem ->get_estimated_time( operation .partition_new .Get_Length_MB( ) ) ;
break ;
case GParted::RESIZE_MOVE:
set_proper_filesystem( operation .partition_new .filesystem ) ;
if ( p_filesystem )
return p_filesystem ->get_estimated_time( std::abs( operation .partition_original .Get_Length_MB( ) - operation .partition_new .Get_Length_MB( ) ) ) ;
break ;
case GParted::COPY:
//lets take 10MB/s for the moment..
return operation .partition_new .Get_Length_MB( ) / 10 ;
}
return -1 ; //pulsing
}
void GParted_Core::Apply_Operation_To_Disk( Operation & operation )
{ {
switch ( operation .operationtype ) switch ( operation .operationtype )
{ {
case DELETE: case DELETE:
if ( ! Delete( operation .partition_original ) ) return Delete( operation .partition_original, operation .operation_details .sub_details ) ;
Show_Error( String::ucompose( _("Error while deleting %1"), operation .partition_original .partition ) ) ;
break;
case CREATE: case CREATE:
if ( ! Create( operation .device, operation .partition_new ) ) return create( operation .device,
Show_Error( String::ucompose( _("Error while creating %1"), operation .partition_new .partition ) ); operation .partition_new,
operation .operation_details .sub_details ) ;
break;
case RESIZE_MOVE: case RESIZE_MOVE:
if ( ! Resize( operation .device, operation .partition_original, operation .partition_new ) ) return resize( operation .device,
Show_Error( String::ucompose( _("Error while resizing/moving %1"), operation .partition_new .partition ) ) ; operation .partition_original,
operation .partition_new,
break; operation .operation_details .sub_details ) ;
case FORMAT: case FORMAT:
if ( ! format( operation .partition_new ) ) return format( operation .partition_new, operation .operation_details .sub_details ) ;
Show_Error( String::ucompose( _("Error while formattting filesystem of %1"), operation .partition_new .partition ) ) ; case COPY:
return copy( operation .copied_partition_path,
break; operation .partition_new,
case COPY: operation .operation_details .sub_details ) ;
if ( ! Copy( operation .copied_partition_path, operation .partition_new ) )
Show_Error( String::ucompose( _("Error while copying %1"), operation .partition_new .partition ) ) ;
} }
return false ;
} }
bool GParted_Core::Create( const Device & device, Partition & new_partition ) bool GParted_Core::create( const Device & device,
Partition & new_partition,
std::vector<OperationDetails> & operation_details )
{ {
if ( new_partition .type == GParted::TYPE_EXTENDED )
return Create_Empty_Partition( new_partition ) ;
else if ( Create_Empty_Partition( new_partition, ( new_partition .Get_Length_MB( ) - device .cylsize ) < get_fs( new_partition .filesystem ) .MIN ) > 0 ) if ( new_partition .type == GParted::TYPE_EXTENDED )
{
return create_empty_partition( new_partition, operation_details ) ;
}
else if ( create_empty_partition(
new_partition,
operation_details,
( new_partition .Get_Length_MB() - device .cylsize ) < get_fs( new_partition .filesystem ) .MIN ) > 0 )
{ {
set_proper_filesystem( new_partition .filesystem ) ; set_proper_filesystem( new_partition .filesystem ) ;
@ -542,24 +514,26 @@ bool GParted_Core::Create( const Device & device, Partition & new_partition )
//however in theory, it could also screw some errorhandling. //however in theory, it could also screw some errorhandling.
if ( ! p_filesystem ) if ( ! p_filesystem )
return true ; return true ;
return set_partition_type( new_partition ) && p_filesystem ->Create( new_partition ) ; return set_partition_type( new_partition, operation_details ) &&
p_filesystem ->Create( new_partition, operation_details ) ;
} }
return false ; return false ;
} }
bool GParted_Core::format( const Partition & partition ) bool GParted_Core::format( const Partition & partition, std::vector<OperationDetails> & operation_details )
{ {
//remove all filesystem signatures... //remove all filesystem signatures...
erase_filesystem_signatures( partition ) ; erase_filesystem_signatures( partition ) ;
set_proper_filesystem( partition .filesystem ) ; set_proper_filesystem( partition .filesystem ) ;
return set_partition_type( partition ) && p_filesystem ->Create( partition ) ; return set_partition_type( partition, operation_details ) &&
p_filesystem ->Create( partition, operation_details ) ;
} }
bool GParted_Core::Delete( const Partition & partition ) bool GParted_Core::Delete( const Partition & partition, std::vector<OperationDetails> & operation_details )
{ {
bool return_value = false ; bool return_value = false ;
@ -579,54 +553,70 @@ bool GParted_Core::Delete( const Partition & partition )
return return_value ; return return_value ;
} }
bool GParted_Core::Resize( const Device & device, const Partition & partition_old, const Partition & partition_new ) bool GParted_Core::resize( const Device & device,
const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetails> & operation_details )
{ {
if ( partition_old .type == GParted::TYPE_EXTENDED ) if ( partition_old .type == GParted::TYPE_EXTENDED )
return Resize_Container_Partition( partition_old, partition_new, false ) ; return resize_container_partition( partition_old, partition_new, false, operation_details ) ;
//lazy check (only grow). it's possbile one day this should be separated in checks for grow,shrink,move .. //lazy check (only grow). it's possbile one day this should be separated in checks for grow,shrink,move ..
if ( get_fs( partition_old .filesystem ) .grow == GParted::FS::LIBPARTED ) if ( get_fs( partition_old .filesystem ) .grow == GParted::FS::LIBPARTED )
return Resize_Normal_Using_Libparted( partition_old, partition_new ) ; return resize_normal_using_libparted( partition_old, partition_new, operation_details ) ;
else //use custom resize tools.. else //use custom resize tools..
{ {
set_proper_filesystem( partition_new .filesystem ) ; set_proper_filesystem( partition_new .filesystem ) ;
if ( p_filesystem ->Check_Repair( partition_new ) ) if ( p_filesystem ->Check_Repair( partition_new, operation_details ) )
{ {//FIXME hier moet betere errorchecking!! momenteel kan er iets fout gaan en wordt de operatie toch
//als geslaagd gerapporteerd. ik ben er groot voorstander van om alles weer te fixen mbv resize e.d.
//maar de status moet wel correct zijn!
//shrinking //shrinking
if ( partition_new .Get_Length_MB( ) < partition_old .Get_Length_MB( ) ) if ( partition_new .Get_Length_MB() < partition_old .Get_Length_MB() )
{ {
p_filesystem ->cylinder_size = device .cylsize ; p_filesystem ->cylinder_size = device .cylsize ;
if ( p_filesystem ->Resize( partition_new ) ) if ( p_filesystem ->Resize( partition_new, operation_details ) )
Resize_Container_Partition( partition_old, partition_new, ! get_fs( partition_new .filesystem ) .move ) ; resize_container_partition(
partition_old,
partition_new,
! get_fs( partition_new .filesystem ) .move,
operation_details ) ;
} }
//growing/moving //growing/moving
else else
Resize_Container_Partition( partition_old, partition_new, ! get_fs( partition_new .filesystem ) .move ) ; resize_container_partition(
partition_old,
partition_new,
! get_fs( partition_new .filesystem ) .move,
operation_details ) ;
p_filesystem ->Check_Repair( partition_new ) ; p_filesystem ->Check_Repair( partition_new, operation_details ) ;
p_filesystem ->Resize( partition_new, true ) ; //expand filesystem to fit exactly in partition //expand filesystem to fit exactly in partition
p_filesystem ->Resize( partition_new, operation_details, true ) ;
return p_filesystem ->Check_Repair( partition_new ) ; return p_filesystem ->Check_Repair( partition_new, operation_details ) ;
} }
} }
return false ; return false ;
} }
bool GParted_Core::Copy( const Glib::ustring & src_part_path, Partition & partition_dest ) bool GParted_Core::copy( const Glib::ustring & src_part_path,
Partition & partition_dest,
std::vector<OperationDetails> & operation_details )
{ {
set_proper_filesystem( partition_dest .filesystem ) ; set_proper_filesystem( partition_dest .filesystem ) ;
Partition src_partition ; Partition src_partition ;
src_partition .partition = src_part_path ; src_partition .partition = src_part_path ;
//FIXME set correct type of dest partition
if ( p_filesystem ->Check_Repair( src_partition ) ) if ( p_filesystem ->Check_Repair( src_partition, operation_details ) )
if ( Create_Empty_Partition( partition_dest, true ) > 0 ) if ( create_empty_partition( partition_dest, operation_details, true ) > 0 )
return p_filesystem ->Copy( src_part_path, partition_dest .partition ) ; return p_filesystem ->Copy( src_part_path, partition_dest .partition, operation_details ) ;
return false ; return false ;
} }
@ -667,11 +657,6 @@ const FS & GParted_Core::get_fs( GParted::FILESYSTEM filesystem ) const
return FILESYSTEMS .back( ) ; return FILESYSTEMS .back( ) ;
} }
Glib::RefPtr<Gtk::TextBuffer> GParted_Core::get_textbuffer( )
{
return textbuffer ;
}
std::vector<Glib::ustring> GParted_Core::get_disklabeltypes( ) std::vector<Glib::ustring> GParted_Core::get_disklabeltypes( )
{ {
std::vector<Glib::ustring> disklabeltypes ; std::vector<Glib::ustring> disklabeltypes ;
@ -716,8 +701,12 @@ void GParted_Core::LP_Set_Used_Sectors( Partition & partition )
} }
} }
int GParted_Core::Create_Empty_Partition( Partition & new_partition, bool copy ) int GParted_Core::create_empty_partition( Partition & new_partition,
std::vector<OperationDetails> & operation_details,
bool copy )
{ {
operation_details .push_back( OperationDetails( _("create empty partition") ) ) ;
new_partition .partition_number = 0 ; new_partition .partition_number = 0 ;
if ( open_device_and_disk( new_partition .device_path ) ) if ( open_device_and_disk( new_partition .device_path ) )
@ -782,13 +771,26 @@ int GParted_Core::Create_Empty_Partition( Partition & new_partition, bool copy )
erase_filesystem_signatures( new_partition ) erase_filesystem_signatures( new_partition )
) )
) )
{
operation_details .back() .status = new_partition .partition_number > 0 ?
OperationDetails::SUCCES : OperationDetails::ERROR ;
return new_partition .partition_number ; return new_partition .partition_number ;
}
else else
return 0 ; {
operation_details .back() .status = OperationDetails::ERROR ;
return 0 ;
}
} }
bool GParted_Core::Resize_Container_Partition( const Partition & partition_old, const Partition & partition_new, bool fixed_start ) bool GParted_Core::resize_container_partition( const Partition & partition_old,
const Partition & partition_new,
bool fixed_start,
std::vector<OperationDetails> & operation_details )
{ {
operation_details .push_back( OperationDetails( _("resize partition") ) ) ;
bool return_value = false ; bool return_value = false ;
PedConstraint *constraint = NULL ; PedConstraint *constraint = NULL ;
@ -828,13 +830,25 @@ bool GParted_Core::Resize_Container_Partition( const Partition & partition_old,
} }
if ( partition_old .type == GParted::TYPE_EXTENDED ) if ( partition_old .type == GParted::TYPE_EXTENDED )
{
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
return return_value ; return return_value ;
}
else else
return wait_for_node( partition_new .partition ) && return_value ; {
return_value &= wait_for_node( partition_new .partition ) ;
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
return return_value ;
}
} }
bool GParted_Core::Resize_Normal_Using_Libparted( const Partition & partition_old, const Partition & partition_new ) bool GParted_Core::resize_normal_using_libparted( const Partition & partition_old,
const Partition & partition_new,
std::vector<OperationDetails> & operation_details )
{ {
operation_details .push_back( OperationDetails( _("resize partition and filesystem using libparted") ) ) ;
bool return_value = false ; bool return_value = false ;
PedFileSystem *fs = NULL ; PedFileSystem *fs = NULL ;
@ -867,6 +881,7 @@ bool GParted_Core::Resize_Normal_Using_Libparted( const Partition & partition_ol
close_device_and_disk( ) ; close_device_and_disk( ) ;
} }
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
return return_value ; return return_value ;
} }
@ -881,17 +896,6 @@ Glib::ustring GParted_Core::Get_Flags( )
return temp ; return temp ;
} }
void GParted_Core::Show_Error( Glib::ustring message )
{
message = "<span weight=\"bold\" size=\"larger\">" + message + "</span>\n\n" ;
message += _( "Be aware that the failure to apply this operation could affect other operations on the list." ) ;
Gtk::MessageDialog dialog( message ,true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true );
gdk_threads_enter( );
dialog .run( );
gdk_threads_leave( );
}
void GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem ) void GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem )
{ {
if ( p_filesystem ) if ( p_filesystem )
@ -914,14 +918,14 @@ void GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem )
default : p_filesystem = NULL ; default : p_filesystem = NULL ;
} }
if ( p_filesystem )
p_filesystem ->textbuffer = textbuffer ;
} }
bool GParted_Core::set_partition_type( const Partition & partition ) bool GParted_Core::set_partition_type( const Partition & partition,
std::vector<OperationDetails> & operation_details )
{ {
operation_details .push_back( OperationDetails( _("set partitiontype") ) ) ;
bool return_value = false ; bool return_value = false ;
if ( open_device_and_disk( partition .device_path ) ) if ( open_device_and_disk( partition .device_path ) )
@ -943,6 +947,7 @@ bool GParted_Core::set_partition_type( const Partition & partition )
close_device_and_disk( ) ; close_device_and_disk( ) ;
} }
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
return return_value ; return return_value ;
} }

View File

@ -19,6 +19,10 @@
namespace GParted namespace GParted
{ {
Operation::Operation()
{
}
Operation::Operation( const Device & device, const Partition & partition_original, const Partition & partition_new, OperationType operationtype ) Operation::Operation( const Device & device, const Partition & partition_original, const Partition & partition_new, OperationType operationtype )
{ {
this ->device = device ; this ->device = device ;

View File

@ -18,6 +18,7 @@
#include "../include/Win_GParted.h" #include "../include/Win_GParted.h"
#include <gtkmm/aboutdialog.h> #include <gtkmm/aboutdialog.h>
#include <gtkmm/messagedialog.h>
#include <cerrno> #include <cerrno>
#include <sys/swap.h> #include <sys/swap.h>
@ -350,9 +351,8 @@ void Win_GParted::init_operationslist( )
liststore_operations = Gtk::ListStore::create( treeview_operations_columns ); liststore_operations = Gtk::ListStore::create( treeview_operations_columns );
treeview_operations .set_model( liststore_operations ); treeview_operations .set_model( liststore_operations );
treeview_operations .set_headers_visible( false ); treeview_operations .set_headers_visible( false );
treeview_operations .append_column( "", treeview_operations_columns .operation_number ); treeview_operations .append_column( "", treeview_operations_columns .operation_icon );
treeview_operations .append_column( "", treeview_operations_columns .operation_description ); treeview_operations .append_column( "", treeview_operations_columns .operation_description );
treeview_operations .get_column( 0 ) ->pack_start( treeview_operations_columns .operation_icon, false );
treeview_operations .get_selection( ) ->set_mode( Gtk::SELECTION_NONE ); treeview_operations .get_selection( ) ->set_mode( Gtk::SELECTION_NONE );
//init scrollwindow_operations //init scrollwindow_operations
@ -497,6 +497,30 @@ void Win_GParted::Add_Operation( OperationType operationtype, const Partition &
{ {
Operation operation( devices[ current_device ], selected_partition, new_partition, operationtype ); Operation operation( devices[ current_device ], selected_partition, new_partition, operationtype );
switch ( operationtype )
{
case GParted::DELETE :
operation .operation_icon =
render_icon( Gtk::Stock::DELETE, Gtk::ICON_SIZE_MENU );
break;
case GParted::CREATE :
operation .operation_icon =
render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU );
break;
case GParted::RESIZE_MOVE:
operation .operation_icon =
render_icon( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU );
break;
case GParted::FORMAT :
operation .operation_icon =
render_icon( Gtk::Stock::CONVERT, Gtk::ICON_SIZE_MENU );
break;
case GParted::COPY :
operation .operation_icon =
render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU );
break;
}
operations.push_back( operation ); operations.push_back( operation );
allow_undo( true ); allow_undo( true );
@ -525,31 +549,8 @@ void Win_GParted::Refresh_Visual( )
operations[ t ] .Apply_Operation_To_Visual( partitions ) ; operations[ t ] .Apply_Operation_To_Visual( partitions ) ;
treerow = *( liststore_operations ->append() ); treerow = *( liststore_operations ->append() );
treerow[ treeview_operations_columns .operation_number ] = t +1;
treerow[ treeview_operations_columns .operation_description ] = operations[ t ] .str_operation ; treerow[ treeview_operations_columns .operation_description ] = operations[ t ] .str_operation ;
switch ( operations[ t ] .operationtype ) treerow[ treeview_operations_columns .operation_icon ] = operations[ t ] .operation_icon ;
{
case GParted::DELETE :
treerow[ treeview_operations_columns.operation_icon ] =
render_icon( Gtk::Stock::DELETE, Gtk::ICON_SIZE_MENU );
break;
case GParted::CREATE :
treerow[ treeview_operations_columns.operation_icon ] =
render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU );
break;
case GParted::RESIZE_MOVE:
treerow[ treeview_operations_columns.operation_icon ] =
render_icon( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU );
break;
case GParted::FORMAT :
treerow[ treeview_operations_columns.operation_icon ] =
render_icon( Gtk::Stock::CONVERT, Gtk::ICON_SIZE_MENU );
break;
case GParted::COPY :
treerow[ treeview_operations_columns.operation_icon ] =
render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU );
break;
}
} }
//set new statusbartext //set new statusbartext
@ -1360,37 +1361,29 @@ void Win_GParted::activate_undo( )
void Win_GParted::activate_apply( ) void Win_GParted::activate_apply( )
{ {
str_temp = "<span weight=\"bold\" size=\"larger\">" ; Gtk::MessageDialog dialog( *this,
str_temp += _( "Are you sure you want to apply the pending operations?" ) ; _( "Are you sure you want to apply the pending operations?" ),
str_temp += "</span>\n\n" ; false,
str_temp += _( "It is recommended to backup valuable data before proceeding.") ; Gtk::MESSAGE_WARNING,
Gtk::BUTTONS_NONE,
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE, true ); true );
dialog .set_secondary_text( _( "It is recommended to backup valuable data before proceeding.") ) ;
dialog .set_title( _( "Apply operations to harddisk" ) ); dialog .set_title( _( "Apply operations to harddisk" ) );
dialog .add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL ); dialog .add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
dialog .add_button( Gtk::Stock::APPLY, Gtk::RESPONSE_OK ); dialog .add_button( Gtk::Stock::APPLY, Gtk::RESPONSE_OK );
dialog .show_all_children( ) ; dialog .show_all_children() ;
if ( dialog.run( ) == Gtk::RESPONSE_OK ) if ( dialog.run() == Gtk::RESPONSE_OK )
{ {
dialog .hide( ) ; //hide confirmationdialog dialog .hide() ; //hide confirmationdialog
apply = true; Dialog_Progress dialog_progress( operations ) ;
dialog_progress = new Dialog_Progress ( operations .size( ), gparted_core .get_textbuffer( ) ) ; dialog_progress .signal_apply_operation .connect(
sigc::mem_fun(gparted_core, &GParted_Core::apply_operation_to_disk) ) ;
conn = dispatcher .connect( sigc::mem_fun(*dialog_progress, &Dialog_Progress::Set_Operation) );
for ( ; dialog_progress .run() != Gtk::RESPONSE_OK ; ) {}
thread = Glib::Thread::create( SigC::slot_class( *this, &Win_GParted::apply_operations_thread ), true ); dialog_progress .hide() ;
dialog_progress ->set_transient_for( *this );
while ( dialog_progress ->run( ) != Gtk::RESPONSE_OK )
apply = false ;//finish current operation . then stop applying operations
//after hiding the progressdialog
delete ( dialog_progress ) ;
thread ->join( ) ;
conn .disconnect( ) ;
//find out if any of the involved devices is busy //find out if any of the involved devices is busy
bool any_busy = false ; bool any_busy = false ;
@ -1411,35 +1404,20 @@ void Win_GParted::activate_apply( )
str_temp += _("Because making changes to a busy device may confuse the kernel, you are advised to reboot your computer.") ; str_temp += _("Because making changes to a busy device may confuse the kernel, you are advised to reboot your computer.") ;
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true ); Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true );
dialog .run( ) ; dialog .run() ;
} }
//wipe operations... //wipe operations...
operations.clear( ) ; operations.clear() ;
liststore_operations ->clear( ) ; liststore_operations ->clear() ;
close_operationslist( ) ; close_operationslist() ;
//reset new_count to 1 //reset new_count to 1
new_count = 1 ; new_count = 1 ;
//reread devices and their layouts... //reread devices and their layouts...
menu_gparted_refresh_devices( ) ; menu_gparted_refresh_devices() ;
} }
} }
void Win_GParted::apply_operations_thread( )
{
for ( unsigned int t = 0 ; t < operations .size( ) && apply ; t++ )
{
dialog_progress ->current_operation = operations[ t ] .str_operation ;
dialog_progress ->TIME_LEFT = gparted_core .get_estimated_time( operations[ t ] ) ;
dispatcher( ) ;
gparted_core .Apply_Operation_To_Disk( operations[ t ] );
}
dialog_progress ->response( Gtk::RESPONSE_OK );
}
} // GParted } // GParted

View File

@ -15,7 +15,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "../include/ext2.h" #include "../include/ext2.h"
namespace GParted namespace GParted
@ -80,43 +79,102 @@ void ext2::Set_Used_Sectors( Partition & partition )
partition .Set_Unused( N * S / 512 ) ; partition .Set_Unused( N * S / 512 ) ;
} }
bool ext2::Create( const Partition & new_partition ) bool ext2::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "mkfs.ext2 " + new_partition .partition ) ; operation_details .push_back( OperationDetails( String::ucompose(
} _("create new %1 filesystem"),
Utils::Get_Filesystem_String( GParted::FS_EXT2 ) ) ) ) ;
bool ext2::Resize( const Partition & partition_new, bool fill_partition ) argv .clear() ;
{ argv .push_back( "mkfs.ext2" ) ;
Glib::ustring str_temp = "resize2fs " + partition_new .partition ; argv .push_back( new_partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
if ( ! fill_partition )
str_temp += " " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ;
return ! Execute_Command( str_temp ) ;
}
bool ext2::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
{
if ( ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) )
{ {
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
bool ext2::Resize( const Partition & partition_new,
std::vector<OperationDetails> & operation_details,
bool fill_partition )
{
if ( fill_partition )
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
else
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
argv .clear() ;
argv .push_back( "resize2fs" ) ;
argv .push_back( partition_new .partition ) ;
if ( ! fill_partition )
argv .push_back( Utils::num_to_str( partition_new .Get_Length_MB() - cylinder_size, true ) + "M" ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
bool ext2::Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails(
String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ;
argv .clear() ;
argv .push_back( "dd" ) ;
argv .push_back( "bs=8192" ) ;
argv .push_back( "if=" + src_part_path ) ;
argv .push_back( "of=" + dest_part_path ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
Partition partition ; Partition partition ;
partition .partition = dest_part_path ; partition .partition = dest_part_path ;
return Resize( partition, true ) ; return Resize( partition, operation_details, true ) ;
} }
operation_details .back() .status = OperationDetails::ERROR ;
return false ; return false ;
} }
bool ext2::Check_Repair( const Partition & partition ) bool ext2::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
{ {
return Execute_Command( "e2fsck -fy " + partition .partition ) <= 1 ; operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
}
int ext2::get_estimated_time( long MB_to_Consider )
{
return -1 ;
}
argv .clear() ;
argv .push_back( "e2fsck" ) ;
argv .push_back( "-f" ) ;
argv .push_back( "-y" ) ;
argv .push_back( "-v" ) ;
argv .push_back( partition .partition ) ;
if ( 1 >= execute_command( argv, operation_details .back() .sub_details ) >= 0 )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
} //GParted } //GParted

View File

@ -80,41 +80,101 @@ void ext3::Set_Used_Sectors( Partition & partition )
partition .Set_Unused( N * S / 512 ) ; partition .Set_Unused( N * S / 512 ) ;
} }
bool ext3::Create( const Partition & new_partition ) bool ext3::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "mkfs.ext3 " + new_partition .partition ) ; operation_details .push_back( OperationDetails( String::ucompose(
} _("create new %1 filesystem"),
Utils::Get_Filesystem_String( GParted::FS_EXT3 ) ) ) ) ;
bool ext3::Resize( const Partition & partition_new, bool fill_partition ) argv .clear() ;
{ argv .push_back( "mkfs.ext3" ) ;
Glib::ustring str_temp = "resize2fs " + partition_new .partition ; argv .push_back( new_partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
if ( ! fill_partition )
str_temp += " " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ;
return ! Execute_Command( str_temp ) ;
}
bool ext3::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
{
if ( ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) )
{ {
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
bool ext3::Resize( const Partition & partition_new,
std::vector<OperationDetails> & operation_details,
bool fill_partition )
{
if ( fill_partition )
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
else
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
argv .clear() ;
argv .push_back( "resize2fs" ) ;
argv .push_back( partition_new .partition ) ;
if ( ! fill_partition )
argv .push_back( Utils::num_to_str( partition_new .Get_Length_MB() - cylinder_size, true ) + "M" ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
bool ext3::Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails(
String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ;
argv .clear() ;
argv .push_back( "dd" ) ;
argv .push_back( "bs=8192" ) ;
argv .push_back( "if=" + src_part_path ) ;
argv .push_back( "of=" + dest_part_path ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
Partition partition ; Partition partition ;
partition .partition = dest_part_path ; partition .partition = dest_part_path ;
return Resize( partition, true ) ; return Resize( partition, operation_details, true ) ;
} }
operation_details .back() .status = OperationDetails::ERROR ;
return false ; return false ;
} }
bool ext3::Check_Repair( const Partition & partition ) bool ext3::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
{ {
return Execute_Command( "e2fsck -fy " + partition .partition ) <= 1 ; operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
}
argv .clear() ;
argv .push_back( "e2fsck" ) ;
argv .push_back( "-f" ) ;
argv .push_back( "-y" ) ;
argv .push_back( "-v" ) ;
argv .push_back( partition .partition ) ;
int ext3::get_estimated_time( long MB_to_Consider ) if ( 1 >= execute_command( argv, operation_details .back() .sub_details ) >= 0 )
{ {
return -1 ; operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
} //GParted } //GParted

View File

@ -54,6 +54,7 @@ FS fat16::get_filesystem_support( )
void fat16::Set_Used_Sectors( Partition & partition ) void fat16::Set_Used_Sectors( Partition & partition )
{ {
argv .push_back( "dosfsck" ) ; argv .push_back( "dosfsck" ) ;
argv .push_back( "-a" ) ;
argv .push_back( "-v" ) ; argv .push_back( "-v" ) ;
argv .push_back( partition .partition ) ; argv .push_back( partition .partition ) ;
@ -85,32 +86,84 @@ void fat16::Set_Used_Sectors( Partition & partition )
partition .Set_Unused( N * S / 512 ) ; partition .Set_Unused( N * S / 512 ) ;
} }
bool fat16::Create( const Partition & new_partition ) bool fat16::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "mkdosfs -F16 " + new_partition .partition ) ; operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::Get_Filesystem_String( GParted::FS_FAT16 ) ) ) ) ;
argv .clear() ;
argv .push_back( "mkdosfs" ) ;
argv .push_back( "-F16" ) ;
argv .push_back( "-v" ) ;
argv .push_back( new_partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
bool fat16::Resize( const Partition & partition_new, bool fill_partition ) bool fat16::Resize( const Partition & partition_new,
std::vector<OperationDetails> & operation_details,
bool fill_partition )
{ {
//handled in GParted_Core::Resize_Normal_Using_Libparted //handled in GParted_Core::resize_normal_using_libparted
return false ; return false ;
} }
bool fat16::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool fat16::Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; operation_details .push_back( OperationDetails(
} String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ;
bool fat16::Check_Repair( const Partition & partition )
{
return ! Execute_Command( "dosfsck -aw " + partition .partition ) ;
}
int fat16::get_estimated_time( long MB_to_Consider )
{
return -1 ;
}
argv .clear() ;
argv .push_back( "dd" ) ;
argv .push_back( "bs=8192" ) ;
argv .push_back( "if=" + src_part_path ) ;
argv .push_back( "of=" + dest_part_path ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
bool fat16::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
argv .clear() ;
argv .push_back( "dosfsck" ) ;
argv .push_back( "-a" ) ;
argv .push_back( "-w" ) ;
argv .push_back( "-v" ) ;
argv .push_back( partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
} //GParted } //GParted

View File

@ -53,6 +53,7 @@ FS fat32::get_filesystem_support( )
void fat32::Set_Used_Sectors( Partition & partition ) void fat32::Set_Used_Sectors( Partition & partition )
{ {
argv .push_back( "dosfsck" ) ; argv .push_back( "dosfsck" ) ;
argv .push_back( "-a" ) ;
argv .push_back( "-v" ) ; argv .push_back( "-v" ) ;
argv .push_back( partition .partition ) ; argv .push_back( partition .partition ) ;
@ -84,33 +85,82 @@ void fat32::Set_Used_Sectors( Partition & partition )
partition .Set_Unused( N * S / 512 ) ; partition .Set_Unused( N * S / 512 ) ;
} }
bool fat32::Create( const Partition & new_partition ) bool fat32::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "mkdosfs -F32 " + new_partition .partition ) ; operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::Get_Filesystem_String( GParted::FS_FAT32 ) ) ) ) ;
argv .clear() ;
argv .push_back( "mkdosfs" ) ;
argv .push_back( "-F32" ) ;
argv .push_back( "-v" ) ;
argv .push_back( new_partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
bool fat32::Resize( const Partition & partition_new, bool fill_partition ) bool fat32::Resize( const Partition & partition_new,
std::vector<OperationDetails> & operation_details,
bool fill_partition )
{ {
//handled in GParted_Core::Resize_Normal_Using_Libparted //handled in GParted_Core::Resize_Normal_Using_Libparted
return false ; return false ;
} }
bool fat32::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool fat32::Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; operation_details .push_back( OperationDetails(
} String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ;
bool fat32::Check_Repair( const Partition & partition )
{
return ! Execute_Command( "dosfsck -aw " + partition .partition ) ;
}
int fat32::get_estimated_time( long MB_to_Consider )
{
return -1 ;
}
argv .clear() ;
argv .push_back( "dd" ) ;
argv .push_back( "bs=8192" ) ;
argv .push_back( "if=" + src_part_path ) ;
argv .push_back( "of=" + dest_part_path ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
bool fat32::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
argv .clear() ;
argv .push_back( "dosfsck" ) ;
argv .push_back( "-a" ) ;
argv .push_back( "-w" ) ;
argv .push_back( "-v" ) ;
argv .push_back( partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
} //GParted } //GParted

View File

@ -44,31 +44,62 @@ void hfs::Set_Used_Sectors( Partition & partition )
{ {
} }
bool hfs::Create( const Partition & new_partition ) bool hfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "hformat " + new_partition .partition ) ; operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::Get_Filesystem_String( GParted::FS_HFS ) ) ) ) ;
argv .clear() ;
argv .push_back( "hformat" ) ;
argv .push_back( new_partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
bool hfs::Resize( const Partition & partition_new, bool fill_partition ) bool hfs::Resize( const Partition & partition_new,
std::vector<OperationDetails> & operation_details,
bool fill_partition )
{ {
return true ; return true ;
} }
bool hfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool hfs::Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; operation_details .push_back( OperationDetails(
} String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ;
bool hfs::Check_Repair( const Partition & partition )
{
return true ;
}
int hfs::get_estimated_time( long MB_to_Consider )
{
return -1 ;
}
argv .clear() ;
argv .push_back( "dd" ) ;
argv .push_back( "bs=8192" ) ;
argv .push_back( "if=" + src_part_path ) ;
argv .push_back( "of=" + dest_part_path ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
bool hfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
{
return true ;
}
} //GParted } //GParted

View File

@ -36,32 +36,30 @@ void hfsplus::Set_Used_Sectors( Partition & partition )
{ {
} }
bool hfsplus::Create( const Partition & new_partition ) bool hfsplus::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{ {
return true ; return true ;
} }
bool hfsplus::Resize( const Partition & partition_new, bool fill_partition ) bool hfsplus::Resize( const Partition & partition_new,
std::vector<OperationDetails> & operation_details,
bool fill_partition )
{ {
return true ; return true ;
} }
bool hfsplus::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool hfsplus::Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details )
{ {
return true ; return true ;
} }
bool hfsplus::Check_Repair( const Partition & partition ) bool hfsplus::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
{ {
return true ; return true ;
} }
int hfsplus::get_estimated_time( long MB_to_Consider )
{
return -1 ;
}
} //GParted } //GParted

View File

@ -91,13 +91,36 @@ void jfs::Set_Used_Sectors( Partition & partition )
pclose( f ) ; pclose( f ) ;
} }
bool jfs::Create( const Partition & new_partition ) bool jfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "mkfs.jfs -q " + new_partition .partition ) ; operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::Get_Filesystem_String( GParted::FS_JFS ) ) ) ) ;
argv .clear() ;
argv .push_back( "mkfs.jfs" ) ;
argv .push_back( "-q" ) ;
argv .push_back( new_partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
bool jfs::Resize( const Partition & partition_new, bool fill_partition ) bool jfs::Resize( const Partition & partition_new,
{ std::vector<OperationDetails> & operation_details,
bool fill_partition )
{//FIXME (no jfs on my laptop, so couldn't test it properly)
if ( fill_partition )
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
else
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
bool return_value = false ; bool return_value = false ;
Glib::ustring error ; Glib::ustring error ;
Glib::ustring TEMP_MP = "/tmp/gparted_tmp_jfs_mountpoint" ; Glib::ustring TEMP_MP = "/tmp/gparted_tmp_jfs_mountpoint" ;
@ -111,31 +134,56 @@ bool jfs::Resize( const Partition & partition_new, bool fill_partition )
} }
rmdir( TEMP_MP .c_str() ) ; rmdir( TEMP_MP .c_str() ) ;
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
return return_value ; return return_value ;
} }
bool jfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool jfs::Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details )
{ {
if ( ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) operation_details .push_back( OperationDetails(
String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ;
argv .clear() ;
argv .push_back( "dd" ) ;
argv .push_back( "bs=8192" ) ;
argv .push_back( "if=" + src_part_path ) ;
argv .push_back( "of=" + dest_part_path ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{ {
operation_details .back() .status = OperationDetails::SUCCES ;
Partition partition ; Partition partition ;
partition .partition = dest_part_path ; partition .partition = dest_part_path ;
return Resize( partition, true ) ; return Resize( partition, operation_details, true ) ;
} }
operation_details .back() .status = OperationDetails::ERROR ;
return false ; return false ;
} }
bool jfs::Check_Repair( const Partition & partition ) bool jfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
{ {
return Execute_Command( "jfs_fsck -f " + partition .partition ) <= 1 ; operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
}
int jfs::get_estimated_time( long MB_to_Consider )
{
return -1 ;
}
argv .clear() ;
argv .push_back( "jfs_fsck" ) ;
argv .push_back( "-f" ) ;
argv .push_back( partition .partition ) ;
if ( 1 >= execute_command( argv, operation_details .back() .sub_details ) >= 0 )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
} //GParted } //GParted

View File

@ -45,30 +45,61 @@ void linux_swap::Set_Used_Sectors( Partition & partition )
{ {
} }
bool linux_swap::Create( const Partition & new_partition ) bool linux_swap::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "mkswap " + new_partition .partition ) ; operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::Get_Filesystem_String( GParted::FS_LINUX_SWAP ) ) ) ) ;
argv .clear() ;
argv .push_back( "mkswap" ) ;
argv .push_back( new_partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
bool linux_swap::Resize( const Partition & partition_new, bool fill_partition ) bool linux_swap::Resize( const Partition & partition_new,
std::vector<OperationDetails> & operation_details,
bool fill_partition )
{ {
return Create( partition_new ) ; return Create( partition_new, operation_details ) ;
} }
bool linux_swap::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool linux_swap::Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "LC_NUMERIC=C dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; operation_details .push_back( OperationDetails(
String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ;
argv .clear() ;
argv .push_back( "dd" ) ;
argv .push_back( "bs=8192" ) ;
argv .push_back( "if=" + src_part_path ) ;
argv .push_back( "of=" + dest_part_path ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
bool linux_swap::Check_Repair( const Partition & partition ) bool linux_swap::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
{ {
return true ; return true ;
} }
int linux_swap::get_estimated_time( long MB_to_Consider )
{
return 1 + MB_to_Consider / 5000 ;
}
} //GParted } //GParted

View File

@ -17,6 +17,7 @@
#include "../include/Win_GParted.h" #include "../include/Win_GParted.h"
#include <gtkmm/messagedialog.h>
int main( int argc, char *argv[ ] ) int main( int argc, char *argv[ ] )
{ {

View File

@ -77,46 +77,101 @@ void ntfs::Set_Used_Sectors( Partition & partition )
partition .Set_Unused( N ) ; partition .Set_Unused( N ) ;
} }
bool ntfs::Create( const Partition & new_partition ) bool ntfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "mkntfs -Q " + new_partition .partition ) ; operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::Get_Filesystem_String( GParted::FS_NTFS ) ) ) ) ;
argv .clear() ;
argv .push_back( "mkntfs" ) ;
argv .push_back( "-Q" ) ;
argv .push_back( "-vv" ) ;
argv .push_back( new_partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
bool ntfs::Resize( const Partition & partition_new, bool fill_partition ) bool ntfs::Resize( const Partition & partition_new,
{ std::vector<OperationDetails> & operation_details,
bool fill_partition )
{//FIXME probeer dmv piping y the echoen in ntfsresize
//-contact szaka en probeer een --yes oid in de API te krijgen
//-perform eerst testruns e.d. in ntfsresize te bouwen..
if ( fill_partition )
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
else
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
Glib::ustring str_temp = "echo y | ntfsresize -f " + partition_new .partition ; Glib::ustring str_temp = "echo y | ntfsresize -f " + partition_new .partition ;
if ( ! fill_partition ) if ( ! fill_partition )
str_temp += " -s " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ; str_temp += " -s " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ;
return ! Execute_Command( str_temp ) ; if ( ! Execute_Command( str_temp ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
bool ntfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool ntfs::Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details )
{ {
if ( ! Execute_Command( "ntfsclone -f --overwrite " + dest_part_path + " " + src_part_path ) ) operation_details .push_back( OperationDetails(
String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ;
argv .clear() ;
argv .push_back( "ntfsclone" ) ;
argv .push_back( "-f" ) ;
argv .push_back( "--overwrite" ) ;
argv .push_back( dest_part_path ) ;
argv .push_back( src_part_path ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{ {
operation_details .back() .status = OperationDetails::SUCCES ;
Partition partition ; Partition partition ;
partition .partition = dest_part_path ; partition .partition = dest_part_path ;
return Resize( partition, true ) ; return Resize( partition, operation_details, true ) ;
} }
operation_details .back() .status = OperationDetails::ERROR ;
return false ; return false ;
} }
bool ntfs::Check_Repair( const Partition & partition ) bool ntfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
{ {
//according to Szaka it's best to use ntfsresize to check the partition for errors //according to Szaka it's best to use ntfsresize to check the partition for errors
//since --info is read-only i'll leave it out. just calling ntfsresize --force has also a tendency of fixing stuff :) //since --info is read-only i'll leave it out. just calling ntfsresize --force has also a tendency of fixing stuff :)
return Resize( partition, true ) ; operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
//FIXME.. ook hier kan eea verbeterd/verduidelijkt..
if ( Resize( partition, operation_details .back() .sub_details, true ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
int ntfs::get_estimated_time( long MB_to_Consider )
{
return -1 ;
}
} //GParted } //GParted

View File

@ -73,31 +73,62 @@ void reiser4::Set_Used_Sectors( Partition & partition )
partition .Set_Unused( N * S / 512 ) ; partition .Set_Unused( N * S / 512 ) ;
} }
bool reiser4::Create( const Partition & new_partition ) bool reiser4::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "mkfs.reiser4 --yes " + new_partition .partition ) ; operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::Get_Filesystem_String( GParted::FS_REISER4 ) ) ) ) ;
argv .clear() ;
argv .push_back( "mkfs.reiser4" ) ;
argv .push_back( "--yes" ) ;
argv .push_back( new_partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
bool reiser4::Resize( const Partition & partition_new, bool fill_partition ) bool reiser4::Resize( const Partition & partition_new,
std::vector<OperationDetails> & operation_details,
bool fill_partition )
{ {
return true ; return true ;
} }
bool reiser4::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool reiser4::Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details )
{ {
return true ; return true ;
} }
bool reiser4::Check_Repair( const Partition & partition ) bool reiser4::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "fsck.reiser4 --yes --fix " + partition .partition ) ; operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
}
int reiser4::get_estimated_time( long MB_to_Consider )
{
return -1 ;
}
argv .clear() ;
argv .push_back( "fsck.reiser4" ) ;
argv .push_back( "--yes" ) ;
argv .push_back( "--fix" ) ;
argv .push_back( partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
} //GParted } //GParted

View File

@ -83,47 +83,102 @@ void reiserfs::Set_Used_Sectors( Partition & partition )
partition .Set_Unused( N * S / 512 ) ; partition .Set_Unused( N * S / 512 ) ;
} }
bool reiserfs::Create( const Partition & new_partition ) bool reiserfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "mkreiserfs -q " + new_partition .partition ) ; operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::Get_Filesystem_String( GParted::FS_REISERFS ) ) ) ) ;
argv .clear() ;
argv .push_back( "mkreiserfs" ) ;
argv .push_back( "-f" ) ;
argv .push_back( new_partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
bool reiserfs::Resize( const Partition & partition_new, bool fill_partition ) bool reiserfs::Resize( const Partition & partition_new,
{ std::vector<OperationDetails> & operation_details,
bool fill_partition )
{//FIXME implement use of execute_command() for improved feedback
if ( fill_partition )
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
else
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
Glib::ustring str_temp = "echo y | resize_reiserfs " + partition_new .partition ; Glib::ustring str_temp = "echo y | resize_reiserfs " + partition_new .partition ;
if ( ! fill_partition ) if ( ! fill_partition )
str_temp += " -s " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ; str_temp += " -s " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ;
return ! Execute_Command( str_temp ) ; if ( ! Execute_Command( str_temp ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
bool reiserfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool reiserfs::Copy( const Glib::ustring & src_part_path,
const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details )
{ {
if ( ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) operation_details .push_back( OperationDetails(
String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ;
argv .clear() ;
argv .push_back( "dd" ) ;
argv .push_back( "bs=8192" ) ;
argv .push_back( "if=" + src_part_path ) ;
argv .push_back( "of=" + dest_part_path ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{ {
operation_details .back() .status = OperationDetails::SUCCES ;
Partition partition ; Partition partition ;
partition .partition = dest_part_path ; partition .partition = dest_part_path ;
return Resize( partition, true ) ; return Resize( partition, operation_details, true ) ;
} }
operation_details .back() .status = OperationDetails::ERROR ;
return false ; return false ;
} }
bool reiserfs::Check_Repair( const Partition & partition ) bool reiserfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
{ {
operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
argv .clear() ;
argv .push_back( "reiserfsck" ) ;
argv .push_back( "--y" ) ;
argv .push_back( "--fix-fixable" ) ;
argv .push_back( partition .partition ) ;
//according to the manpage it should return 0 or 1 on succes, instead it returns 256 on succes.. //according to the manpage it should return 0 or 1 on succes, instead it returns 256 on succes..
//blah, don't have time for this. Just check for both options, we'll fix this later with our much improved errorhandling //blah, don't have time for this. Just check for both options
int t = Execute_Command( "reiserfsck -y --fix-fixable " + partition .partition ) ; exit_status = execute_command( argv, operation_details .back() .sub_details ) ;
if ( exit_status == 0 || exit_status == 1 || exit_status == 256 )
return ( t <= 1 || t == 256 ) ; {
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
int reiserfs::get_estimated_time( long MB_to_Consider )
{
return -1 ;
}
} //GParted } //GParted

View File

@ -94,13 +94,36 @@ void xfs::Set_Used_Sectors( Partition & partition )
partition .Set_Unused( N * S / 512 ) ; partition .Set_Unused( N * S / 512 ) ;
} }
bool xfs::Create( const Partition & new_partition ) bool xfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "mkfs.xfs -f " + new_partition .partition ) ; operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::Get_Filesystem_String( GParted::FS_XFS ) ) ) ) ;
argv .clear() ;
argv .push_back( "mkfs.xfs" ) ;
argv .push_back( "-f" ) ;
argv .push_back( new_partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
} }
bool xfs::Resize( const Partition & partition_new, bool fill_partition ) bool xfs::Resize( const Partition & partition_new,
{ std::vector<OperationDetails> & operation_details,
bool fill_partition )
{//FIXME
if ( fill_partition )
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
else
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
bool return_value = false ; bool return_value = false ;
Glib::ustring error ; Glib::ustring error ;
Glib::ustring TEMP_MP = "/tmp/gparted_tmp_xfs_mountpoint" ; Glib::ustring TEMP_MP = "/tmp/gparted_tmp_xfs_mountpoint" ;
@ -114,11 +137,17 @@ bool xfs::Resize( const Partition & partition_new, bool fill_partition )
} }
rmdir( TEMP_MP .c_str() ) ; rmdir( TEMP_MP .c_str() ) ;
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
return return_value ; return return_value ;
} }
bool xfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) bool xfs::Copy( const Glib::ustring & src_part_path,
{ const Glib::ustring & dest_part_path,
std::vector<OperationDetails> & operation_details )
{//FIXME
operation_details .push_back( OperationDetails(
String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ;
bool return_value = false ; bool return_value = false ;
Glib::ustring error ; Glib::ustring error ;
Glib::ustring SRC = "/tmp/gparted_tmp_xfs_src_mountpoint" ; Glib::ustring SRC = "/tmp/gparted_tmp_xfs_src_mountpoint" ;
@ -139,19 +168,30 @@ bool xfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_
rmdir( SRC .c_str() ) ; rmdir( SRC .c_str() ) ;
rmdir( DST .c_str() ) ; rmdir( DST .c_str() ) ;
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
return return_value ; return return_value ;
} }
bool xfs::Check_Repair( const Partition & partition ) bool xfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
{ {
return ! Execute_Command( "xfs_repair " + partition .partition ) ; operation_details .push_back( OperationDetails( _("check filesystem for errors and (if possible) fix them") ) ) ;
}
int xfs::get_estimated_time( long MB_to_Consider )
{
return -1 ;
}
argv .clear() ;
argv .push_back( "xfs_repair" ) ;
argv .push_back( "-v" ) ;
argv .push_back( partition .partition ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
} //GParted } //GParted