P ). Resizing of ext2/3 works perfect now. I've even tested it on the
* Again way too many chances to create a detailed entry (i'm glad i'm the only dev atm :P ). Resizing of ext2/3 works perfect now. I've even tested it on the partition holding my SG seasons =) Implemented checking of filesystems (only internally used atm). Done some overall tweaking, finetuning etc.. release 0.0.7 is getting shape.
This commit is contained in:
parent
53321675f7
commit
bd02bca613
|
@ -1,3 +1,10 @@
|
|||
2004-11-21 Bart Hakvoort <gparted@users.sf.net>
|
||||
|
||||
* Again way too many chances to create a detailed entry (i'm glad i'm the only dev atm :P ).
|
||||
Resizing of ext2/3 works perfect now. I've even tested it on the partition holding my SG seasons =)
|
||||
Implemented checking of filesystems (only internally used atm).
|
||||
Done some overall tweaking, finetuning etc.. release 0.0.7 is getting shape.
|
||||
|
||||
2004-11-19 Bart Hakvoort <gparted@users.sf.net>
|
||||
|
||||
* include/Device.h,
|
||||
|
|
|
@ -26,9 +26,9 @@ namespace GParted
|
|||
class Dialog_Partition_Copy : public Dialog_Base_Partition
|
||||
{
|
||||
public:
|
||||
Dialog_Partition_Copy() ;
|
||||
void Set_Data( Partition & selected_partition, Partition & copied_partition );
|
||||
Partition Get_New_Partition() ;
|
||||
Dialog_Partition_Copy( ) ;
|
||||
void Set_Data( const Partition & selected_partition, const Partition & copied_partition );
|
||||
Partition Get_New_Partition( ) ;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace GParted
|
|||
class Dialog_Partition_Resize_Move : public Dialog_Base_Partition
|
||||
{
|
||||
public:
|
||||
Dialog_Partition_Resize_Move( std::vector<FS> FILESYSTEMS ) ;
|
||||
Dialog_Partition_Resize_Move( std::vector<FS> FILESYSTEMS, Sector cylinder_size ) ;
|
||||
void Set_Data( const Partition & selected_partition, const std::vector <Partition> & partitions ) ;
|
||||
|
||||
private:
|
||||
|
|
|
@ -78,21 +78,26 @@ namespace GParted
|
|||
class FileSystem
|
||||
{
|
||||
public:
|
||||
FileSystem( ) ;
|
||||
virtual ~FileSystem( ) { }
|
||||
|
||||
virtual FS get_filesystem_support( ) = 0 ;
|
||||
virtual void Set_Used_Sectors( Partition & partition ) = 0 ;
|
||||
virtual bool Create( const Glib::ustring device_path, const Partition & new_partition ) = 0 ;
|
||||
virtual bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) = 0 ;
|
||||
virtual bool Resize( const Partition & partition_new, bool fill_partition = false ) = 0 ;
|
||||
virtual bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) = 0 ;
|
||||
virtual bool Check_Repair( const Partition & partition ) = 0 ;
|
||||
virtual int get_estimated_time( long MB_to_Consider ) = 0 ;
|
||||
|
||||
Glib::RefPtr<Gtk::TextBuffer> textbuffer ;
|
||||
|
||||
PedDisk *disk ; //see GParted_Core::Set_Used_Sectors() ...
|
||||
long cylinder_size ; //see GParted_Core::Resize()
|
||||
|
||||
protected:
|
||||
bool Execute_Command( Glib::ustring command ) ;
|
||||
|
||||
PedDevice *device ;
|
||||
PedDisk *disk ;
|
||||
|
||||
private:
|
||||
void Update_Textview( ) ;
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
void find_supported_filesystems( ) ;
|
||||
void get_devices( std::vector<Device> & devices, bool deep_scan ) ;
|
||||
|
||||
int get_estimated_time( Operation & operation ) ;
|
||||
int get_estimated_time( const Operation & operation ) ;
|
||||
|
||||
void Apply_Operation_To_Disk( Operation & operation );
|
||||
|
||||
|
@ -57,13 +57,15 @@ public:
|
|||
private:
|
||||
void set_device_partitions( Device & device, bool deep_scan = true ) ;
|
||||
Glib::ustring get_sym_path( const Glib::ustring & real_path ) ;
|
||||
Sector Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring & sym_path );
|
||||
void Set_Used_Sectors( Partition & partition );
|
||||
Glib::ustring Get_Flags( PedPartition *c_partition ) ;
|
||||
int Create_Empty_Partition( const Glib::ustring & device_path, Partition & new_partition, bool copy = false ) ;
|
||||
bool Resize_Extended( const Glib::ustring & device_path, const Partition & extended ) ;
|
||||
bool Resize_Container_Partition( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new ) ;
|
||||
bool Resize_Normal_Using_Libparted( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new ) ;
|
||||
|
||||
void Show_Error( Glib::ustring message ) ;
|
||||
void set_proper_filesystem( const Glib::ustring & filesystem ) ;
|
||||
long Get_Cylinder_Size( const Glib::ustring & device_path ) ;
|
||||
|
||||
Glib::RefPtr<Gtk::TextBuffer> textbuffer;
|
||||
|
||||
|
|
|
@ -54,8 +54,6 @@ public:
|
|||
Glib::ustring str_operation ;
|
||||
Glib::ustring copied_partition_path ; //for copy operation..
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void Insert_Unallocated( std::vector<Partition> & partitions, Sector start, Sector end );
|
||||
int Get_Index_Original( std::vector<Partition> & partitions ) ;
|
||||
|
|
|
@ -66,16 +66,16 @@ public:
|
|||
const bool inside_extended,
|
||||
const bool busy ) ;
|
||||
|
||||
void Set_Used( Sector used ) ;
|
||||
void Set_Unused( Sector sectors_unused ) ;
|
||||
|
||||
void Set_Unallocated( Sector sector_start, Sector sector_end, bool inside_extended );
|
||||
|
||||
//update partition number (used when a logical partition is deleted)
|
||||
void Update_Number( int new_number );
|
||||
|
||||
long Get_Length_MB( );
|
||||
long Get_Used_MB( );
|
||||
long Get_Unused_MB( );
|
||||
const long Get_Length_MB( ) const ;
|
||||
const long Get_Used_MB( ) const ;
|
||||
const long Get_Unused_MB( ) const ;
|
||||
|
||||
//some public members
|
||||
Glib::ustring partition;//the symbolic path (e.g. /dev/hda1 )
|
||||
|
|
|
@ -36,20 +36,20 @@ class TreeView_Detail : public Gtk::TreeView
|
|||
{
|
||||
public:
|
||||
TreeView_Detail( );
|
||||
void Load_Partitions( std::vector<Partition> & partitions ) ;
|
||||
void Load_Partitions( const std::vector<Partition> & partitions ) ;
|
||||
void Set_Selected( const Partition & partition );
|
||||
|
||||
//signals for interclass communication
|
||||
sigc::signal<void,GdkEventButton *,const Partition &> signal_mouse_click;
|
||||
sigc::signal<void, GdkEventButton *, const Partition & > signal_mouse_click;
|
||||
|
||||
private:
|
||||
void Create_Row( const Gtk::TreeRow &, Partition &);
|
||||
void Create_Row( const Gtk::TreeRow & treerow, const Partition & partition );
|
||||
|
||||
//overridden signal
|
||||
virtual bool on_button_press_event(GdkEventButton *);
|
||||
|
||||
Gtk::TreeRow row,childrow;
|
||||
Gtk::TreeIter iter,iter_child;
|
||||
Gtk::TreeRow row, childrow;
|
||||
Gtk::TreeIter iter, iter_child;
|
||||
|
||||
Glib::RefPtr<Gtk::TreeStore> treestore_detail;
|
||||
Glib::RefPtr<Gtk::TreeSelection> treeselection;
|
||||
|
@ -69,7 +69,7 @@ private:
|
|||
Gtk::TreeModelColumn<Glib::ustring> flags;
|
||||
Gtk::TreeModelColumn< Partition > partition_struct; //hidden column ( see also on_button_press_event )
|
||||
|
||||
treeview_detail_Columns() {
|
||||
treeview_detail_Columns( ) {
|
||||
add( partition ); add( type ); add( type_square ); add( size ); add( used ); add( unused ); add( color ); add( text_color ); add( status_icon ); add( flags ); add(partition_struct);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -43,12 +43,14 @@ typedef long long Sector;
|
|||
struct FS
|
||||
{
|
||||
Glib::ustring filesystem ;
|
||||
bool read ; //can we get the amount of used sectors?
|
||||
bool create ;
|
||||
bool resize ; //only endpoint
|
||||
bool move ; //startpoint and endpoint
|
||||
bool check ;
|
||||
bool check ; //some checktool available?
|
||||
bool copy ;
|
||||
|
||||
FS( ) {create = resize = move = check = false ;}
|
||||
FS( ) {read = create = resize = move = check = copy = false ;}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class VBox_VisualDisk : public Gtk::VBox
|
|||
|
||||
public:
|
||||
VBox_VisualDisk( const std::vector<Partition> & partitions, const Sector device_length );
|
||||
~VBox_VisualDisk();
|
||||
~VBox_VisualDisk( );
|
||||
void Set_Selected( const Partition & );
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
|
||||
private:
|
||||
void Build_Visual_Disk( ) ; //i still dream of some fully resizeable visualdisk....
|
||||
void Create_Visual_Partition( Partition & partition ) ;
|
||||
void Create_Visual_Partition( const Partition & partition ) ;
|
||||
void Prepare_Legend( std::vector<Glib::ustring> & legend, const std::vector<Partition> & partitions ) ;
|
||||
void Build_Legend( ) ;
|
||||
|
||||
|
|
|
@ -28,9 +28,11 @@ class ext2 : public FileSystem
|
|||
{
|
||||
public:
|
||||
FS get_filesystem_support( ) ;
|
||||
void Set_Used_Sectors( Partition & partition ) ;
|
||||
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
|
||||
bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) ;
|
||||
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
|
||||
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
|
||||
bool Check_Repair( const Partition & partition ) ;
|
||||
int get_estimated_time( long MB_to_Consider ) ;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,9 +28,11 @@ class ext3 : public FileSystem
|
|||
{
|
||||
public:
|
||||
FS get_filesystem_support( ) ;
|
||||
void Set_Used_Sectors( Partition & partition ) ;
|
||||
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
|
||||
bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) ;
|
||||
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
|
||||
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
|
||||
bool Check_Repair( const Partition & partition ) ;
|
||||
int get_estimated_time( long MB_to_Consider ) ;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,9 +28,11 @@ class fat16 : public FileSystem
|
|||
{
|
||||
public:
|
||||
FS get_filesystem_support( ) ;
|
||||
void Set_Used_Sectors( Partition & partition ) ;
|
||||
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
|
||||
bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) ;
|
||||
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
|
||||
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
|
||||
bool Check_Repair( const Partition & partition ) ;
|
||||
int get_estimated_time( long MB_to_Consider ) ;
|
||||
|
||||
};
|
||||
|
|
|
@ -28,9 +28,11 @@ class fat32 : public FileSystem
|
|||
{
|
||||
public:
|
||||
FS get_filesystem_support( );
|
||||
void Set_Used_Sectors( Partition & partition ) ;
|
||||
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
|
||||
bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) ;
|
||||
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
|
||||
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
|
||||
bool Check_Repair( const Partition & partition ) ;
|
||||
int get_estimated_time( long MB_to_Consider ) ;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,9 +28,11 @@ class linux_swap : public FileSystem
|
|||
{
|
||||
public:
|
||||
FS get_filesystem_support( ) ;
|
||||
void Set_Used_Sectors( Partition & partition ) ;
|
||||
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
|
||||
bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) ;
|
||||
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
|
||||
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
|
||||
bool Check_Repair( const Partition & partition ) ;
|
||||
int get_estimated_time( long MB_to_Consider ) ;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,9 +30,11 @@ class reiserfs : public FileSystem
|
|||
{
|
||||
public:
|
||||
FS get_filesystem_support( ) ;
|
||||
void Set_Used_Sectors( Partition & partition ) ;
|
||||
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
|
||||
bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) ;
|
||||
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
|
||||
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
|
||||
bool Check_Repair( const Partition & partition ) ;
|
||||
int get_estimated_time( long MB_to_Consider ) ;
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ Dialog_Partition_Copy::Dialog_Partition_Copy()
|
|||
Set_Confirm_Button( PASTE ) ;
|
||||
}
|
||||
|
||||
void Dialog_Partition_Copy::Set_Data( Partition & selected_partition, Partition & copied_partition )
|
||||
void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, const Partition & copied_partition )
|
||||
{
|
||||
GRIP = true ; //prevents on spinbutton_changed from getting activated prematurely
|
||||
|
||||
|
@ -36,40 +36,40 @@ void Dialog_Partition_Copy::Set_Data( Partition & selected_partition, Partition
|
|||
frame_resizer_base ->set_rgb_partition_color( copied_partition .color ) ;
|
||||
|
||||
//set some widely used values...
|
||||
START = selected_partition.sector_start ;
|
||||
total_length = selected_partition.sector_end - selected_partition.sector_start ;
|
||||
START = selected_partition .sector_start ;
|
||||
total_length = selected_partition .sector_end - selected_partition .sector_start ;
|
||||
TOTAL_MB = selected_partition .Get_Length_MB() ;
|
||||
MB_PER_PIXEL = (double) TOTAL_MB / 500 ;
|
||||
|
||||
//now calculate proportional length of partition
|
||||
frame_resizer_base ->set_x_start( 0 ) ;
|
||||
frame_resizer_base ->set_x_end( ( Round( (double) (copied_partition.sector_end - copied_partition.sector_start) / ( (double)total_length/500) )) ) ;
|
||||
frame_resizer_base ->set_used( frame_resizer_base ->get_x_end() ) ;
|
||||
frame_resizer_base ->set_x_end( ( Round( (double) (copied_partition .sector_end - copied_partition .sector_start) / ( (double)total_length/500) )) ) ;
|
||||
frame_resizer_base ->set_used( frame_resizer_base ->get_x_end( ) ) ;
|
||||
|
||||
//used to store current positions (see Dialog_Base_Partition::on_signal_resize)
|
||||
this ->x_start = frame_resizer_base ->get_x_start( ) ;
|
||||
this ->x_end = frame_resizer_base ->get_x_end( ) ;
|
||||
|
||||
//set values of spinbutton_before
|
||||
spinbutton_before .set_range( 0, TOTAL_MB - copied_partition .Get_Length_MB() -1 ) ;//mind the -1 !!
|
||||
spinbutton_before .set_range( 0, TOTAL_MB - copied_partition .Get_Length_MB( ) -1 ) ;//mind the -1 !!
|
||||
spinbutton_before .set_value( 0 ) ;
|
||||
|
||||
//set values of spinbutton_size (check for fat16 maxsize of 1023 MB)
|
||||
long UPPER;
|
||||
if ( copied_partition.filesystem == "fat16" && Sector_To_MB( total_length ) > 1023 )
|
||||
if ( copied_partition .filesystem == "fat16" && Sector_To_MB( total_length ) > 1023 )
|
||||
UPPER = 1023 ;
|
||||
else
|
||||
UPPER = TOTAL_MB ;
|
||||
|
||||
spinbutton_size .set_range( copied_partition .Get_Length_MB() +1, UPPER ) ;
|
||||
spinbutton_size .set_value( copied_partition .Get_Length_MB() ) ;
|
||||
spinbutton_size .set_range( copied_partition .Get_Length_MB( ) +1, UPPER ) ;
|
||||
spinbutton_size .set_value( copied_partition .Get_Length_MB( ) ) ;
|
||||
|
||||
//set values of spinbutton_after
|
||||
spinbutton_after .set_range( 0, TOTAL_MB - copied_partition .Get_Length_MB() -1 ) ;
|
||||
spinbutton_after .set_value( TOTAL_MB - copied_partition .Get_Length_MB() ) ;
|
||||
spinbutton_after .set_range( 0, TOTAL_MB - copied_partition .Get_Length_MB( ) -1 ) ;
|
||||
spinbutton_after .set_value( TOTAL_MB - copied_partition .Get_Length_MB( ) ) ;
|
||||
|
||||
//set contents of label_minmax
|
||||
Set_MinMax_Text( copied_partition .Get_Length_MB() +1, UPPER ) ;
|
||||
Set_MinMax_Text( copied_partition .Get_Length_MB( ) +1, UPPER ) ;
|
||||
|
||||
//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
|
||||
this ->selected_partition = copied_partition ;
|
||||
|
|
|
@ -27,7 +27,7 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition )
|
|||
this ->set_resizable( false );
|
||||
|
||||
/*TO TRANSLATORS: dialogtitle, looks like Information about /dev/hda3 */
|
||||
this->set_title( String::ucompose( _( "Information about %1"), partition.partition ) );
|
||||
this ->set_title( String::ucompose( _( "Information about %1"), partition .partition ) );
|
||||
|
||||
init_drawingarea( ) ;
|
||||
|
||||
|
@ -44,7 +44,7 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition )
|
|||
|
||||
hbox = manage( new Gtk::HBox( ) );
|
||||
hbox ->pack_start( *image, Gtk::PACK_SHRINK ) ;
|
||||
hbox ->pack_start( * mk_label( "<b> " + (Glib::ustring) _( "Libparted message:" ) + " </b>" ), Gtk::PACK_SHRINK ) ;
|
||||
hbox ->pack_start( * mk_label( "<b> " + (Glib::ustring) _( "Warning:" ) + " </b>" ), Gtk::PACK_SHRINK ) ;
|
||||
|
||||
frame ->set_label_widget( *hbox ) ;
|
||||
frame ->add( * mk_label( "<i>" + partition.error + "</i>", true, true, true ) ) ;
|
||||
|
|
|
@ -42,6 +42,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
|
|||
this ->new_count = new_count;
|
||||
this ->selected_partition = partition;
|
||||
this ->FILESYSTEMS = FILESYSTEMS ;
|
||||
this ->FILESYSTEMS .erase( this ->FILESYSTEMS .end( ) ) ;//remove dummy "unknown"
|
||||
|
||||
FS fs ; fs.filesystem = "extended" ;
|
||||
this ->FILESYSTEMS .push_back( fs ) ;
|
||||
|
@ -169,14 +170,14 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
|||
if (optionmenu_type.get_history() == GParted::EXTENDED )
|
||||
{
|
||||
menu_filesystem.items().push_back(Gtk::Menu_Helpers::MenuElem( "extended") ) ;
|
||||
optionmenu_filesystem.set_history( 6 ) ;
|
||||
optionmenu_filesystem.set_history( 6 ) ;
|
||||
optionmenu_filesystem.set_sensitive( false );
|
||||
}
|
||||
else if ( menu_filesystem.items() .size() > 6 )
|
||||
{
|
||||
menu_filesystem.items() .remove( menu_filesystem.items() .back() );
|
||||
optionmenu_filesystem.set_sensitive( true );
|
||||
optionmenu_filesystem.set_history( 0 ) ;
|
||||
optionmenu_filesystem.set_history( 0 ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
namespace GParted
|
||||
{
|
||||
|
||||
Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move( std::vector<FS> FILESYSTEMS )
|
||||
Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move( std::vector<FS> FILESYSTEMS, Sector cylinder_size )
|
||||
{
|
||||
this ->FILESYSTEMS = FILESYSTEMS ;
|
||||
BUF = 5 ;
|
||||
BUF = Sector_To_MB( cylinder_size ) *2 ;
|
||||
}
|
||||
|
||||
void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partition, const std::vector <Partition> & partitions )
|
||||
|
|
|
@ -21,14 +21,20 @@
|
|||
namespace GParted
|
||||
{
|
||||
|
||||
FileSystem::FileSystem( )
|
||||
{
|
||||
disk = NULL;
|
||||
cylinder_size = 0 ;
|
||||
}
|
||||
|
||||
bool FileSystem::Execute_Command( Glib::ustring command )
|
||||
{
|
||||
Glib::Dispatcher dispatcher;
|
||||
sigc::connection conn = dispatcher .connect( sigc::mem_fun(*this, &FileSystem::Update_Textview) );
|
||||
|
||||
//stderr to stdout
|
||||
command += " 2>&1" ;
|
||||
|
||||
//command += " 2>&1" ;
|
||||
std::cout << command << std::endl ;
|
||||
output = command + "\n\n" ;
|
||||
dispatcher ( ) ;
|
||||
|
||||
|
@ -47,6 +53,7 @@ bool FileSystem::Execute_Command( Glib::ustring command )
|
|||
output = "" ;
|
||||
dispatcher ( ) ;
|
||||
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,25 +3,11 @@
|
|||
namespace GParted
|
||||
{
|
||||
|
||||
//AFAIK it's not possible to use a C++ memberfunction as a callback for a C libary function (if you know otherwise, PLEASE contact me)
|
||||
Glib::ustring error_message;
|
||||
PedExceptionOption PedException_Handler (PedException* ex)
|
||||
{
|
||||
error_message = Glib::locale_to_utf8( ex ->message ) ;
|
||||
|
||||
std::cout << "\nLIBPARTED MESSAGE ----------------------\n" << error_message << "\n---------------------------\n";
|
||||
|
||||
return PED_EXCEPTION_UNHANDLED ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GParted_Core::GParted_Core( )
|
||||
{
|
||||
device = NULL ;
|
||||
disk = NULL ;
|
||||
c_partition = NULL ;
|
||||
ped_exception_set_handler( PedException_Handler ) ;
|
||||
|
||||
p_filesystem = NULL ;
|
||||
textbuffer = Gtk::TextBuffer::create( ) ;
|
||||
|
@ -52,6 +38,10 @@ void GParted_Core::find_supported_filesystems( )
|
|||
|
||||
reiserfs fs_reiserfs;
|
||||
FILESYSTEMS .push_back( fs_reiserfs .get_filesystem_support( ) ) ;
|
||||
|
||||
//unknown filesystem (default when no match is found)
|
||||
FS fs ; fs .filesystem = "unknown" ;
|
||||
FILESYSTEMS .push_back( fs ) ;
|
||||
}
|
||||
|
||||
void GParted_Core::get_devices( std::vector<Device> & devices, bool deep_scan )
|
||||
|
@ -110,7 +100,7 @@ void GParted_Core::get_devices( std::vector<Device> & devices, bool deep_scan )
|
|||
void GParted_Core::set_device_partitions( Device & device, bool deep_scan )
|
||||
{
|
||||
Partition partition_temp ;
|
||||
Glib::ustring part_path, error ;
|
||||
Glib::ustring part_path ;
|
||||
int EXT_INDEX = -1 ;
|
||||
|
||||
//clear partitions
|
||||
|
@ -131,13 +121,13 @@ void GParted_Core::set_device_partitions( Device & device, bool deep_scan )
|
|||
else
|
||||
{
|
||||
temp = "unknown" ;
|
||||
error = _( "Unable to detect filesystem! Possible reasons are:" ) ;
|
||||
error += "\n-";
|
||||
error += _( "The filesystem is damaged" ) ;
|
||||
error += "\n-" ;
|
||||
error += _( "The filesystem is unknown to libparted" ) ;
|
||||
error += "\n-";
|
||||
error += _( "There is no filesystem available (unformatted)" ) ;
|
||||
partition_temp .error = _( "Unable to detect filesystem! Possible reasons are:" ) ;
|
||||
partition_temp .error += "\n-";
|
||||
partition_temp .error += _( "The filesystem is damaged" ) ;
|
||||
partition_temp .error += "\n-" ;
|
||||
partition_temp .error += _( "The filesystem is unknown to libparted" ) ;
|
||||
partition_temp .error += "\n-";
|
||||
partition_temp .error += _( "There is no filesystem available (unformatted)" ) ;
|
||||
|
||||
}
|
||||
partition_temp .Set( part_path,
|
||||
|
@ -148,11 +138,21 @@ void GParted_Core::set_device_partitions( Device & device, bool deep_scan )
|
|||
c_partition ->type,
|
||||
ped_partition_is_busy( c_partition ) );
|
||||
|
||||
if ( deep_scan )
|
||||
partition_temp .Set_Used( Get_Used_Sectors( c_partition, part_path ) ) ;
|
||||
if ( deep_scan && partition_temp .filesystem != "linux-swap" )
|
||||
{
|
||||
Set_Used_Sectors( partition_temp ) ;
|
||||
|
||||
//the 'Unknow' filesystem warning overrules this one
|
||||
if ( partition_temp .sectors_used == -1 && partition_temp .error .empty( ) )
|
||||
{
|
||||
partition_temp .error = _("Unable to read the contents of this filesystem!") ;
|
||||
partition_temp .error += "\n" ;
|
||||
partition_temp .error += ("As a result you won't be able to resize this partition.") ;
|
||||
}
|
||||
}
|
||||
|
||||
partition_temp .flags = Get_Flags( c_partition ) ;
|
||||
partition_temp .error = error .empty( ) ? error_message : error ;
|
||||
|
||||
|
||||
if ( partition_temp .busy )
|
||||
device .busy = true ;
|
||||
|
@ -203,16 +203,13 @@ void GParted_Core::set_device_partitions( Device & device, bool deep_scan )
|
|||
device .device_partitions[ EXT_INDEX ] .logicals .push_back( partition_temp ) ;
|
||||
}
|
||||
|
||||
//reset stuff..
|
||||
error = error_message = "" ;
|
||||
|
||||
//next partition (if any)
|
||||
c_partition = ped_disk_next_partition ( disk, c_partition ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int GParted_Core::get_estimated_time( Operation & operation )
|
||||
int GParted_Core::get_estimated_time( const Operation & operation )
|
||||
{
|
||||
switch ( operation .operationtype )
|
||||
{
|
||||
|
@ -269,13 +266,9 @@ void GParted_Core::Apply_Operation_To_Disk( Operation & operation )
|
|||
case COPY:
|
||||
if ( ! Copy( operation .device_path, operation .copied_partition_path, operation .partition_new ) )
|
||||
Show_Error( String::ucompose( _("Error while copying %1"), operation .partition_new .partition ) ) ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool GParted_Core::Create( const Glib::ustring & device_path, Partition & new_partition )
|
||||
{
|
||||
if ( new_partition .type == GParted::EXTENDED )
|
||||
|
@ -316,16 +309,45 @@ bool GParted_Core::Delete( const Glib::ustring & device_path, const Partition &
|
|||
return return_value ;
|
||||
}
|
||||
|
||||
bool GParted_Core::Resize(const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new )
|
||||
bool GParted_Core::Resize( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new )
|
||||
{
|
||||
if ( partition_old .type == GParted::EXTENDED )
|
||||
return Resize_Extended( device_path, partition_new ) ;
|
||||
return Resize_Container_Partition( device_path, partition_old, partition_new ) ;
|
||||
|
||||
//these 3 still use libparted's resizer.
|
||||
else if ( partition_old .filesystem == "linux-swap" ||
|
||||
partition_old .filesystem == "fat16" ||
|
||||
partition_old .filesystem == "fat32"
|
||||
)
|
||||
return Resize_Normal_Using_Libparted( device_path, partition_old, partition_new ) ;
|
||||
|
||||
//use custom resize tools..(afaik only resize, no moves)
|
||||
else
|
||||
{
|
||||
set_proper_filesystem( partition_new .filesystem ) ;
|
||||
|
||||
return p_filesystem ->Resize( device_path, partition_old, partition_new ) ;
|
||||
if ( p_filesystem ->Check_Repair( partition_new ) )
|
||||
{
|
||||
//shrinking
|
||||
if ( partition_new .sector_end < partition_old .sector_end )
|
||||
{
|
||||
p_filesystem ->cylinder_size = Get_Cylinder_Size( device_path ) ;
|
||||
|
||||
if ( p_filesystem ->Resize( partition_new ) )
|
||||
Resize_Container_Partition( device_path, partition_old, partition_new ) ;
|
||||
}
|
||||
|
||||
//growing
|
||||
if ( partition_new .sector_end > partition_old .sector_end )
|
||||
Resize_Container_Partition( device_path, partition_old, partition_new ) ;
|
||||
|
||||
|
||||
p_filesystem ->Check_Repair( partition_new ) ;
|
||||
|
||||
p_filesystem ->Resize( partition_new, true ) ; //expand filesystem to fit exactly in partition
|
||||
|
||||
return p_filesystem ->Check_Repair( partition_new ) ;
|
||||
}
|
||||
}
|
||||
|
||||
return false ;
|
||||
|
@ -383,64 +405,32 @@ Glib::ustring GParted_Core::get_sym_path( const Glib::ustring & real_path )
|
|||
}
|
||||
|
||||
|
||||
Sector GParted_Core::Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring & sym_path)
|
||||
void GParted_Core::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
/* This is quite an unreliable process, atm i try two different methods, but since both are far from perfect the results are
|
||||
* questionable.
|
||||
* - first i try geometry.get_used() in libpartedpp, i implemented this function to check the minimal size when resizing a partition. Disadvantage
|
||||
* of this method is the fact it won't work on mounted filesystems. Besides that, its SLOW
|
||||
* - if the former method fails ( result is -1 ) i'll try to read the output from the df command ( df -k --sync <partition path> )
|
||||
* - if this fails the filesystem on the partition is ( more or less ) unknown to the operating system and therefore the unused sectors cannot be calcualted
|
||||
* - as soon as i have my internetconnection back i should ask people with more experience on this stuff for advice !
|
||||
*/
|
||||
if ( partition .filesystem == "unknown" || partition .filesystem == "linux-swap" )
|
||||
partition .Set_Unused( -1 ) ;
|
||||
|
||||
//check if there is a (known) filesystem
|
||||
if ( ! c_partition ->fs_type )
|
||||
return -1;
|
||||
|
||||
//used sectors are not relevant for swapspace
|
||||
if ( (Glib::ustring) c_partition ->fs_type ->name == "linux-swap" )
|
||||
return -1;
|
||||
|
||||
//METHOD #1
|
||||
//the getused method doesn't work on mounted partitions and for some filesystems ( i *guess* this is called check by andrew )
|
||||
if ( ! ped_partition_is_busy( c_partition ) && Get_FS( c_partition ->fs_type ->name, FILESYSTEMS ) .create )
|
||||
else if ( partition .busy )
|
||||
{
|
||||
PedFileSystem *fs = NULL;
|
||||
PedConstraint *constraint = NULL;
|
||||
|
||||
fs = ped_file_system_open( & c_partition ->geom );
|
||||
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint (fs);
|
||||
ped_file_system_close (fs);
|
||||
if ( constraint && constraint->min_size != -1 )
|
||||
return constraint->min_size ;
|
||||
}
|
||||
}
|
||||
|
||||
//METHOD #2
|
||||
//this ony works for mounted ( and therefore known to the OS ) filesystems. My method is quite crude, keep in mind it's only temporary ;-)
|
||||
if ( ped_partition_is_busy( c_partition ) )
|
||||
{
|
||||
Glib::ustring buf;
|
||||
system( ("df -k --sync " + sym_path + " | grep " + sym_path + " > /tmp/.tmp_gparted") .c_str( ) );
|
||||
system( ("df -k --sync " + partition .partition + " | grep " + partition .partition + " > /tmp/.tmp_gparted") .c_str( ) );
|
||||
std::ifstream file_input( "/tmp/.tmp_gparted" );
|
||||
|
||||
file_input >> buf; //skip first value
|
||||
file_input >> buf;
|
||||
if ( buf != "0" && ! buf .empty( ) )
|
||||
{
|
||||
file_input >> buf;
|
||||
file_input .close( ); system( "rm -f /tmp/.tmp_gparted" );
|
||||
return atoi( buf .c_str( ) ) * 1024/512 ;
|
||||
}
|
||||
file_input .close( ); system( "rm -f /tmp/.tmp_gparted" );
|
||||
//we need the 4th value
|
||||
file_input >> temp; file_input >> temp; file_input >> temp;file_input >> temp;
|
||||
if ( ! temp .empty( ) )
|
||||
partition .Set_Unused( atoi( temp .c_str( ) ) * 1024/512 ) ;
|
||||
|
||||
file_input .close( );
|
||||
system( "rm -f /tmp/.tmp_gparted" );
|
||||
}
|
||||
|
||||
else if ( Get_FS( partition .filesystem, FILESYSTEMS ) .read )
|
||||
{
|
||||
set_proper_filesystem( partition .filesystem ) ;
|
||||
|
||||
return -1 ; //all methods were unsuccesfull
|
||||
p_filesystem ->disk = disk ;
|
||||
p_filesystem ->Set_Used_Sectors( partition ) ;
|
||||
}
|
||||
}
|
||||
|
||||
int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Partition & new_partition, bool copy )
|
||||
|
@ -491,28 +481,70 @@ int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Par
|
|||
return new_partition .partition_number ;
|
||||
}
|
||||
|
||||
bool GParted_Core::Resize_Extended( const Glib::ustring & device_path, const Partition & extended )
|
||||
bool GParted_Core::Resize_Container_Partition( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new )
|
||||
{
|
||||
bool return_value = false ;
|
||||
|
||||
PedConstraint *constraint = NULL ;
|
||||
c_partition = NULL ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
{
|
||||
PedPartition *c_part = NULL ;
|
||||
PedConstraint *constraint = NULL ;
|
||||
if ( partition_old .type == GParted::EXTENDED )
|
||||
c_partition = ped_disk_extended_partition( disk ) ;
|
||||
else
|
||||
c_partition = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
|
||||
c_part = ped_disk_extended_partition( disk ) ;
|
||||
if ( c_part )
|
||||
if ( c_partition )
|
||||
{
|
||||
constraint = ped_constraint_any ( device );
|
||||
constraint = ped_constraint_any( device );
|
||||
if ( constraint )
|
||||
{
|
||||
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, extended .sector_start, extended .sector_end ) )
|
||||
{
|
||||
ped_partition_set_system ( c_part, NULL );
|
||||
if ( ped_disk_set_partition_geom ( disk, c_partition, constraint, partition_new .sector_start, partition_new .sector_end ) )
|
||||
return_value = Commit( disk ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
}
|
||||
|
||||
sleep( 1 ) ; //the OS needs time to re-add the devicenode..
|
||||
|
||||
return return_value ;
|
||||
}
|
||||
|
||||
bool GParted_Core::Resize_Normal_Using_Libparted( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new )
|
||||
{
|
||||
bool return_value = false ;
|
||||
|
||||
PedFileSystem *fs = NULL ;
|
||||
PedConstraint *constraint = NULL ;
|
||||
c_partition = NULL ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
{
|
||||
c_partition = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
if ( c_partition )
|
||||
{
|
||||
fs = ped_file_system_open ( & c_partition ->geom );
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs );
|
||||
if ( constraint )
|
||||
{
|
||||
if ( ped_disk_set_partition_geom ( disk, c_partition, constraint, partition_new .sector_start, partition_new .sector_end ) &&
|
||||
ped_file_system_resize ( fs, & c_partition ->geom, NULL )
|
||||
)
|
||||
return_value = Commit( disk ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_constraint_destroy (constraint);
|
||||
ped_file_system_close ( fs );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -570,4 +602,18 @@ void GParted_Core::set_proper_filesystem( const Glib::ustring & filesystem )
|
|||
p_filesystem ->textbuffer = textbuffer ;
|
||||
}
|
||||
|
||||
long GParted_Core::Get_Cylinder_Size( const Glib::ustring & device_path )
|
||||
{
|
||||
long cylinder_size = 0 ;
|
||||
|
||||
if ( open_device( device_path, device ) )
|
||||
{
|
||||
cylinder_size = Sector_To_MB( device ->bios_geom .heads * device ->bios_geom .sectors ) ;
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
}
|
||||
|
||||
return cylinder_size ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -56,38 +56,37 @@ void Partition::Set( const Glib::ustring & partition,
|
|||
this ->busy = busy;
|
||||
}
|
||||
|
||||
void Partition::Set_Used( Sector used )
|
||||
void Partition::Set_Unused( Sector sectors_unused )
|
||||
{
|
||||
this ->sectors_used = used;
|
||||
this ->sectors_unused = ( used == -1 ) ? -1 : ( sector_end - sector_start) - used ;
|
||||
this ->sectors_unused = sectors_unused ;
|
||||
this ->sectors_used = ( sectors_unused == -1 ) ? -1 : ( sector_end - sector_start) - sectors_unused ;
|
||||
}
|
||||
|
||||
void Partition::Set_Unallocated( Sector sector_start, Sector sector_end, bool inside_extended )
|
||||
{
|
||||
this ->Set( _("Unallocated"), -1, GParted::UNALLOCATED, "unallocated", sector_start, sector_end , inside_extended, false);
|
||||
this ->Set( _("Unallocated"), -1, GParted::UNALLOCATED, "unallocated", sector_start, sector_end , inside_extended, false );
|
||||
this ->error = this ->flags = "" ;
|
||||
this ->status = GParted::STAT_REAL ;
|
||||
}
|
||||
|
||||
void Partition::Update_Number( int new_number )
|
||||
{ //of course this fails when we have devicenames with numbers over 99
|
||||
partition_number >= 10 ? partition = partition.substr( 0, partition.length() -2 ) : partition = partition.substr( 0, partition.length() -1 ) ;
|
||||
|
||||
partition = partition .substr( 0, partition .length( ) - ( partition_number >= 10 ? 2 : 1 ) ) ;
|
||||
this ->partition_number = new_number;
|
||||
this ->partition += num_to_str( partition_number ) ;
|
||||
}
|
||||
|
||||
long Partition::Get_Length_MB( )
|
||||
const long Partition::Get_Length_MB( ) const
|
||||
{
|
||||
return Sector_To_MB( this ->sector_end - this ->sector_start) ;
|
||||
return Sector_To_MB( sector_end - sector_start ) ;
|
||||
}
|
||||
|
||||
long Partition::Get_Used_MB( )
|
||||
const long Partition::Get_Used_MB( ) const
|
||||
{
|
||||
return Sector_To_MB( this ->sectors_used) ;
|
||||
return Sector_To_MB( this ->sectors_used ) ;
|
||||
}
|
||||
|
||||
long Partition::Get_Unused_MB( )
|
||||
const long Partition::Get_Unused_MB( ) const
|
||||
{
|
||||
return Get_Length_MB( ) - Get_Used_MB( ) ;
|
||||
}
|
||||
|
|
|
@ -70,53 +70,58 @@ TreeView_Detail::TreeView_Detail( )
|
|||
|
||||
}
|
||||
|
||||
void TreeView_Detail::Load_Partitions( std::vector<Partition> & partitions )
|
||||
void TreeView_Detail::Load_Partitions( const std::vector<Partition> & partitions )
|
||||
{
|
||||
treestore_detail ->clear() ;
|
||||
treestore_detail ->clear( ) ;
|
||||
|
||||
for ( unsigned int i=0;i<partitions.size();i++ )
|
||||
for ( unsigned int i = 0 ; i < partitions .size( ) ; i++ )
|
||||
{
|
||||
row = *(treestore_detail->append());
|
||||
Create_Row( row, partitions[i] );
|
||||
row = *( treestore_detail ->append( ) );
|
||||
Create_Row( row, partitions[ i ] );
|
||||
|
||||
if ( partitions[i] .type == GParted::EXTENDED )
|
||||
if ( partitions[ i ] .type == GParted::EXTENDED )
|
||||
{
|
||||
for ( unsigned int t=0;t<partitions[i] .logicals .size();t++ )
|
||||
for ( unsigned int t = 0 ; t < partitions[ i ] .logicals .size( ) ; t++ )
|
||||
{
|
||||
childrow = *(treestore_detail->append( row.children() ));
|
||||
Create_Row( childrow, partitions[i] .logicals[ t ] );
|
||||
childrow = *( treestore_detail ->append( row.children( ) ) );
|
||||
Create_Row( childrow, partitions[ i ] .logicals[ t ] );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//show logical partitions ( if any )
|
||||
this->expand_all();
|
||||
this ->expand_all( );
|
||||
}
|
||||
|
||||
void TreeView_Detail::Set_Selected( const Partition & partition )
|
||||
{
|
||||
//look for appropiate row
|
||||
for(iter = treestore_detail->children().begin();iter!=treestore_detail->children().end();iter++ )
|
||||
for( iter = treestore_detail ->children( ) .begin( ) ; iter != treestore_detail ->children( ) .end( ) ; iter++ )
|
||||
{
|
||||
row = *iter;
|
||||
partition_temp = row[treeview_detail_columns.partition_struct] ;
|
||||
partition_temp = row[ treeview_detail_columns.partition_struct ] ;
|
||||
//primary's
|
||||
if ( partition .sector_start >= partition_temp .sector_start && partition .sector_end <=partition_temp .sector_end && partition.inside_extended == partition_temp.inside_extended )
|
||||
{ this->set_cursor( (Gtk::TreePath) row); return; }
|
||||
if ( partition .sector_start >= partition_temp .sector_start &&
|
||||
partition .sector_end <=partition_temp .sector_end &&
|
||||
partition.inside_extended == partition_temp.inside_extended )
|
||||
{
|
||||
this ->set_cursor( (Gtk::TreePath) row );
|
||||
return;
|
||||
}
|
||||
|
||||
//logicals
|
||||
if ( row.children().size() > 0 ) //this is the row with the extended partition, search it's childrows...
|
||||
if ( row .children( ) .size( ) > 0 ) //this is the row with the extended partition, search it's childrows...
|
||||
{
|
||||
for(iter_child = row.children().begin();iter_child != row.children().end();iter_child++ )
|
||||
for( iter_child = row .children( ) .begin( ) ; iter_child != row.children( ) .end( ) ; iter_child++ )
|
||||
{
|
||||
childrow = *iter_child;
|
||||
partition_temp = childrow[treeview_detail_columns.partition_struct] ;
|
||||
partition_temp = childrow[ treeview_detail_columns.partition_struct ] ;
|
||||
|
||||
if ( partition .sector_start >= partition_temp .sector_start && partition .sector_end <= partition_temp.sector_end )
|
||||
if ( partition .sector_start >= partition_temp .sector_start && partition .sector_end <= partition_temp .sector_end )
|
||||
{
|
||||
this->expand_all();
|
||||
this->set_cursor( (Gtk::TreePath) childrow);
|
||||
this ->expand_all( );
|
||||
this ->set_cursor( (Gtk::TreePath) childrow );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -127,54 +132,54 @@ void TreeView_Detail::Set_Selected( const Partition & partition )
|
|||
|
||||
}
|
||||
|
||||
void TreeView_Detail::Create_Row( const Gtk::TreeRow & treerow, Partition & partition )
|
||||
void TreeView_Detail::Create_Row( const Gtk::TreeRow & treerow, const Partition & partition )
|
||||
{
|
||||
//hereby i assume these 2 are mutual exclusive. is this wise?? Time (and bugreports) will tell :)
|
||||
if ( partition.busy )
|
||||
treerow[treeview_detail_columns.status_icon] = render_icon(Gtk::Stock::DIALOG_AUTHENTICATION, Gtk::ICON_SIZE_BUTTON);
|
||||
else if ( partition.filesystem == "unknown" || partition .error != "" )
|
||||
treerow[treeview_detail_columns.status_icon] = render_icon(Gtk::Stock::DIALOG_WARNING, Gtk::ICON_SIZE_BUTTON);
|
||||
if ( partition .busy )
|
||||
treerow[ treeview_detail_columns .status_icon ] = render_icon( Gtk::Stock::DIALOG_AUTHENTICATION, Gtk::ICON_SIZE_BUTTON );
|
||||
else if ( partition .filesystem == "unknown" || partition .error != "" )
|
||||
treerow[ treeview_detail_columns .status_icon ] = render_icon( Gtk::Stock::DIALOG_WARNING, Gtk::ICON_SIZE_BUTTON );
|
||||
|
||||
treerow[treeview_detail_columns.partition] = partition.partition;
|
||||
treerow[treeview_detail_columns.color] = Get_Color( partition .filesystem ) ;
|
||||
treerow[ treeview_detail_columns .partition ] = partition .partition;
|
||||
treerow[ treeview_detail_columns .color ] = Get_Color( partition .filesystem ) ;
|
||||
|
||||
partition .type == GParted::UNALLOCATED ? treerow[treeview_detail_columns.text_color] = "darkgrey" : treerow[treeview_detail_columns.text_color] = "black" ;
|
||||
treerow[treeview_detail_columns.type] = partition.filesystem ;
|
||||
treerow[ treeview_detail_columns .text_color ] = ( partition .type == GParted::UNALLOCATED ) ? "darkgrey" : "black" ;
|
||||
treerow[ treeview_detail_columns .type ] = partition .filesystem ;
|
||||
treerow[ treeview_detail_columns .type_square ] = "██" ;
|
||||
|
||||
//size
|
||||
treerow[treeview_detail_columns.size] = num_to_str( partition .Get_Length_MB() ) ;
|
||||
treerow[ treeview_detail_columns .size ] = num_to_str( partition .Get_Length_MB( ) ) ;
|
||||
|
||||
//used
|
||||
if ( partition.sectors_used != -1 )
|
||||
treerow[treeview_detail_columns.used] = num_to_str( partition .Get_Used_MB() ) ;
|
||||
if ( partition .sectors_used != -1 )
|
||||
treerow[ treeview_detail_columns .used ] = num_to_str( partition .Get_Used_MB( ) ) ;
|
||||
else
|
||||
treerow[treeview_detail_columns.used] = "---" ;
|
||||
treerow[ treeview_detail_columns .used ] = "---" ;
|
||||
|
||||
//unused
|
||||
if ( partition .sectors_unused != -1 )
|
||||
treerow[treeview_detail_columns.unused] = num_to_str(partition .Get_Unused_MB() ) ;
|
||||
treerow[ treeview_detail_columns .unused ] = num_to_str( partition .Get_Unused_MB( ) ) ;
|
||||
else
|
||||
treerow[treeview_detail_columns.unused] = "---" ;
|
||||
treerow[ treeview_detail_columns .unused ] = "---" ;
|
||||
|
||||
//flags
|
||||
treerow[treeview_detail_columns.flags] = " " + partition .flags ;
|
||||
treerow[ treeview_detail_columns .flags ] = " " + partition .flags ;
|
||||
|
||||
//hidden column (partition object)
|
||||
treerow[treeview_detail_columns.partition_struct] = partition;
|
||||
treerow[ treeview_detail_columns .partition_struct ] = partition;
|
||||
}
|
||||
|
||||
bool TreeView_Detail::on_button_press_event(GdkEventButton* event)
|
||||
bool TreeView_Detail::on_button_press_event( GdkEventButton* event )
|
||||
{
|
||||
//Call base class, to allow normal handling,
|
||||
bool return_value = TreeView::on_button_press_event(event);
|
||||
bool return_value = TreeView::on_button_press_event( event );
|
||||
|
||||
iter = treeselection->get_selected();
|
||||
iter = treeselection ->get_selected( );
|
||||
|
||||
if ( *iter != 0 )
|
||||
{
|
||||
row = *iter;
|
||||
signal_mouse_click.emit( event, row[treeview_detail_columns.partition_struct] );
|
||||
signal_mouse_click .emit( event, row[ treeview_detail_columns .partition_struct ] );
|
||||
}
|
||||
|
||||
return return_value;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace GParted
|
||||
{
|
||||
|
||||
VBox_VisualDisk::VBox_VisualDisk( const std::vector<Partition> & partitions, const Sector device_length)
|
||||
VBox_VisualDisk::VBox_VisualDisk( const std::vector<Partition> & partitions, const Sector device_length )
|
||||
{
|
||||
this ->partitions = partitions ;
|
||||
this ->device_length = device_length ;
|
||||
|
@ -28,8 +28,8 @@ VBox_VisualDisk::VBox_VisualDisk( const std::vector<Partition> & partitions, con
|
|||
selected_partition = -1;
|
||||
|
||||
//create frame which contains the visual disk
|
||||
frame_disk_legend = manage( new Gtk::Frame() ) ;
|
||||
frame_disk_legend ->set_shadow_type(Gtk::SHADOW_ETCHED_OUT);
|
||||
frame_disk_legend = manage( new Gtk::Frame( ) ) ;
|
||||
frame_disk_legend ->set_shadow_type( Gtk::SHADOW_ETCHED_OUT );
|
||||
frame_disk_legend ->set_border_width( 5 );
|
||||
hbox_disk_main.pack_start( *frame_disk_legend, Gtk::PACK_EXPAND_PADDING );
|
||||
|
||||
|
@ -41,9 +41,9 @@ VBox_VisualDisk::VBox_VisualDisk( const std::vector<Partition> & partitions, con
|
|||
this->pack_start( hbox_disk_main, Gtk::PACK_SHRINK );
|
||||
|
||||
//set and allocated some standard colors
|
||||
color_used.set( "#F8F8BA" ); this ->get_colormap() ->alloc_color( color_used ) ;//bleach yellow ;)
|
||||
color_unused.set( "white" ); this ->get_colormap() ->alloc_color( color_unused ) ;
|
||||
color_text.set( "black" ); this ->get_colormap() ->alloc_color( color_text ) ;
|
||||
color_used.set( "#F8F8BA" ); this ->get_colormap( ) ->alloc_color( color_used ) ;//bleach yellow ;)
|
||||
color_unused.set( "white" ); this ->get_colormap( ) ->alloc_color( color_unused ) ;
|
||||
color_text.set( "black" ); this ->get_colormap( ) ->alloc_color( color_text ) ;
|
||||
|
||||
|
||||
//since disksegments have minimal sizes ( unallocated 15 and partitions 20 pixels ) i do some checking to prevent the visual disk from growing to much
|
||||
|
@ -51,7 +51,7 @@ VBox_VisualDisk::VBox_VisualDisk( const std::vector<Partition> & partitions, con
|
|||
|
||||
double width, extra_pixels = 0 ;
|
||||
|
||||
for ( unsigned int t=0; t<partitions.size() ; t++ )
|
||||
for ( unsigned int t = 0; t < partitions .size( ) ; t++ )
|
||||
{
|
||||
width = (double) (partitions[ t ] .sector_end - partitions[ t ] .sector_start) / sectors_per_pixel ;
|
||||
|
||||
|
@ -72,102 +72,108 @@ void VBox_VisualDisk::Build_Visual_Disk( )
|
|||
{
|
||||
//since there is a 5 pixel space between every partition.... ( extended adds 2 *5 more, but that doesn't matter that much.
|
||||
//NOTE that a part < 20 will also grow to 20, so length in pixels may vary across different devices..
|
||||
this ->SCREEN_WIDTH -= ( (partitions .size() -1) *5 ) ;
|
||||
this ->SCREEN_WIDTH -= ( (partitions .size( ) -1) *5 ) ;
|
||||
|
||||
//create hbox_disk and add to frame
|
||||
hbox_disk = manage( new Gtk::HBox() ) ;
|
||||
hbox_disk = manage( new Gtk::HBox( ) ) ;
|
||||
hbox_disk ->set_spacing( 5 );
|
||||
frame_disk_legend ->add( *hbox_disk );
|
||||
|
||||
|
||||
//walk through all partitions....
|
||||
for ( unsigned int i=0;i<partitions.size();i++ )
|
||||
for ( unsigned int i = 0 ; i < partitions .size( ) ; i++ )
|
||||
{
|
||||
Create_Visual_Partition( partitions[i] ) ;
|
||||
Create_Visual_Partition( partitions[ i ] ) ;
|
||||
|
||||
if ( partitions[i].type != GParted::EXTENDED )
|
||||
hbox_disk ->pack_start( *( visual_partitions.back() ->drawingarea), Gtk::PACK_SHRINK ) ;
|
||||
if ( partitions[ i ].type != GParted::EXTENDED )
|
||||
hbox_disk ->pack_start( *( visual_partitions .back( ) ->drawingarea ), Gtk::PACK_SHRINK ) ;
|
||||
}
|
||||
|
||||
this ->show_all_children() ;
|
||||
this ->show_all_children( ) ;
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::Create_Visual_Partition( Partition & partition )
|
||||
void VBox_VisualDisk::Create_Visual_Partition( const Partition & partition )
|
||||
{
|
||||
int x,y;//for pango_layout check
|
||||
|
||||
visual_partition = new Visual_Partition() ;
|
||||
visual_partitions.push_back( visual_partition ) ;
|
||||
visual_partitions.back() ->index = visual_partitions .size() -1 ; // <---- BELACHELIJK!! DOE DAAR IETS AAN!!!
|
||||
visual_partitions.back() ->sector_start = partition .sector_start ;
|
||||
visual_partition = new Visual_Partition( ) ;
|
||||
visual_partitions .push_back( visual_partition ) ;
|
||||
visual_partitions .back( ) ->index = visual_partitions .size( ) -1 ; // <---- BELACHELIJK!! DOE DAAR IETS AAN!!!
|
||||
visual_partitions .back( ) ->sector_start = partition .sector_start ;
|
||||
|
||||
if ( partition .type == GParted::EXTENDED )
|
||||
{
|
||||
visual_partitions.back() ->drawingarea = NULL ;//it's just a dummy ;-) ( see Set_Selected() )
|
||||
visual_partitions.back() ->length = 0 ; //keeps total_length clean
|
||||
visual_partitions.back( ) ->drawingarea = NULL ;//it's just a dummy ;-) ( see Set_Selected() )
|
||||
visual_partitions.back( ) ->length = 0 ; //keeps total_length clean
|
||||
|
||||
eventbox_extended = manage( new Gtk::EventBox() ) ;
|
||||
eventbox_extended = manage( new Gtk::EventBox( ) ) ;
|
||||
eventbox_extended ->set_size_request( -1, 60 );
|
||||
eventbox_extended ->modify_bg( eventbox_extended ->get_state(), partition .color );
|
||||
eventbox_extended ->modify_bg( eventbox_extended ->get_state( ), partition .color );
|
||||
hbox_disk ->pack_start( *eventbox_extended, Gtk::PACK_SHRINK ) ;
|
||||
|
||||
hbox_extended = manage( new Gtk::HBox() ) ;
|
||||
hbox_extended = manage( new Gtk::HBox( ) ) ;
|
||||
hbox_extended ->set_border_width( 5 );
|
||||
hbox_extended ->set_spacing( 5 );
|
||||
eventbox_extended ->add( *hbox_extended ) ;
|
||||
|
||||
for ( unsigned int t=0;t<partition .logicals .size();t++ )
|
||||
for ( unsigned int t = 0 ; t < partition .logicals .size( ) ; t++ )
|
||||
{
|
||||
Create_Visual_Partition( partition .logicals[ t ] ) ;
|
||||
hbox_extended ->pack_start( *( visual_partitions.back() ->drawingarea), Gtk::PACK_SHRINK ) ;
|
||||
hbox_extended ->pack_start( *( visual_partitions .back( ) ->drawingarea ), Gtk::PACK_SHRINK ) ;
|
||||
}
|
||||
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
visual_partitions.back() ->length = (int) (SCREEN_WIDTH / (double) ( device_length / (double) ( partition .sector_end - partition .sector_start) ) );
|
||||
if ( visual_partitions.back() ->length < 20 )//we need a min. size. Otherwise some small partitions wouldn't be visible
|
||||
partition .type == GParted::UNALLOCATED ? visual_partitions.back() ->length = 15 : visual_partitions.back() ->length = 20 ;
|
||||
visual_partitions .back( ) ->length = (int) (SCREEN_WIDTH / (double) ( device_length / (double) ( partition .sector_end - partition .sector_start) ) );
|
||||
if ( visual_partitions .back( ) ->length < 20 )//we need a min. size. Otherwise some small partitions wouldn't be visible
|
||||
visual_partitions .back( ) ->length = ( partition .type == GParted::UNALLOCATED ) ? 15 : 20 ;
|
||||
|
||||
if ( partition .inside_extended )
|
||||
{ visual_partitions.back() ->height = 34 ; visual_partitions.back() ->text_y = 9 ; }
|
||||
{
|
||||
visual_partitions .back( ) ->height = 34 ;
|
||||
visual_partitions .back( ) ->text_y = 9 ;
|
||||
}
|
||||
else
|
||||
{ visual_partitions.back() ->height = 44 ;visual_partitions.back() ->text_y = 15 ; }
|
||||
{
|
||||
visual_partitions .back( ) ->height = 44 ;
|
||||
visual_partitions .back( ) ->text_y = 15 ;
|
||||
}
|
||||
|
||||
if ( partition .type == GParted::UNALLOCATED )
|
||||
visual_partitions.back() ->used = -1;
|
||||
visual_partitions .back( ) ->used = -1;
|
||||
else
|
||||
visual_partitions.back() ->used = (int) ( (visual_partitions.back() ->length - (BORDER *2)) / (double) ( ( partition .sector_end - partition .sector_start) / (double)partition .sectors_used ) ) ;
|
||||
visual_partitions .back( ) ->used = (int) ( (visual_partitions .back( ) ->length - (BORDER *2)) / (double) ( ( partition .sector_end - partition .sector_start) / (double)partition .sectors_used ) ) ;
|
||||
|
||||
|
||||
visual_partitions.back() ->color_fs = partition .color;
|
||||
this ->get_colormap() ->alloc_color(visual_partitions.back() ->color_fs);
|
||||
visual_partitions.back( ) ->color_fs = partition .color;
|
||||
this ->get_colormap( ) ->alloc_color( visual_partitions .back( ) ->color_fs );
|
||||
|
||||
visual_partitions.back() ->drawingarea = manage( new Gtk::DrawingArea() ) ;
|
||||
visual_partitions.back() ->drawingarea ->set_size_request( visual_partitions.back() ->length +1, 60 );
|
||||
visual_partitions.back() ->drawingarea ->set_events(Gdk::BUTTON_PRESS_MASK);
|
||||
visual_partitions .back( ) ->drawingarea = manage( new Gtk::DrawingArea( ) ) ;
|
||||
visual_partitions .back( ) ->drawingarea ->set_size_request( visual_partitions .back( ) ->length +1, 60 );
|
||||
visual_partitions .back( ) ->drawingarea ->set_events( Gdk::BUTTON_PRESS_MASK );
|
||||
|
||||
//connect signal handlers
|
||||
visual_partitions.back() ->drawingarea ->signal_button_press_event().connect( sigc::bind<Partition>(sigc::mem_fun(*this, &VBox_VisualDisk::on_drawingarea_button_press), partition ) );
|
||||
visual_partitions.back() ->drawingarea ->signal_realize().connect( sigc::bind<Visual_Partition *>(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_realize), visual_partitions.back() ) );
|
||||
visual_partitions.back() ->drawingarea ->signal_expose_event().connect( sigc::bind<Visual_Partition *>(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_expose), visual_partitions.back() ));
|
||||
visual_partitions .back( ) ->drawingarea ->signal_button_press_event( ) .connect( sigc::bind<Partition>(sigc::mem_fun(*this, &VBox_VisualDisk::on_drawingarea_button_press), partition ) );
|
||||
visual_partitions .back( ) ->drawingarea ->signal_realize( ) .connect( sigc::bind<Visual_Partition *>(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_realize), visual_partitions .back( ) ) );
|
||||
visual_partitions .back( ) ->drawingarea ->signal_expose_event( ) .connect( sigc::bind<Visual_Partition *>(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_expose), visual_partitions .back( ) ));
|
||||
|
||||
//create pangolayout and see if it fits in the visual partition
|
||||
str_temp = partition .partition + "\n" + String::ucompose( _("%1 MB"), partition .Get_Length_MB() ) ;
|
||||
visual_partitions.back() ->pango_layout = visual_partitions.back() ->drawingarea ->create_pango_layout ( str_temp ) ;
|
||||
str_temp = partition .partition + "\n" + String::ucompose( _("%1 MB"), partition .Get_Length_MB( ) ) ;
|
||||
visual_partitions .back( ) ->pango_layout = visual_partitions .back( ) ->drawingarea ->create_pango_layout ( str_temp ) ;
|
||||
|
||||
visual_partitions.back() ->pango_layout ->get_pixel_size( x, y ) ;
|
||||
if ( visual_partitions.back() ->length - BORDER * 2 -2 < x )
|
||||
visual_partitions.back() ->pango_layout ->set_text( "" ) ;
|
||||
visual_partitions .back( ) ->pango_layout ->get_pixel_size( x, y ) ;
|
||||
if ( visual_partitions .back( ) ->length - BORDER * 2 -2 < x )
|
||||
visual_partitions .back( ) ->pango_layout ->set_text( "" ) ;
|
||||
|
||||
//tooltip
|
||||
str_temp = "" ;
|
||||
if ( partition .type != GParted::UNALLOCATED )
|
||||
str_temp = partition .filesystem + "\n" ;
|
||||
|
||||
str_temp += partition .partition + "\n" + String::ucompose( _("%1 MB"), partition .Get_Length_MB() ) ;
|
||||
tooltips.set_tip( *(visual_partitions.back() ->drawingarea), str_temp ) ;
|
||||
str_temp += partition .partition + "\n" + String::ucompose( _("%1 MB"), partition .Get_Length_MB( ) ) ;
|
||||
tooltips .set_tip( *( visual_partitions.back( ) ->drawingarea ), str_temp ) ;
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::Prepare_Legend( std::vector<Glib::ustring> & legend, const std::vector<Partition> & partitions )
|
||||
|
@ -256,9 +262,9 @@ void VBox_VisualDisk::Set_Selected( const Partition & partition )
|
|||
|
||||
void VBox_VisualDisk::drawingarea_on_realize( Visual_Partition* vp )
|
||||
{
|
||||
vp ->gc = Gdk::GC::create( vp ->drawingarea ->get_window() );
|
||||
vp ->gc = Gdk::GC::create( vp ->drawingarea ->get_window( ) );
|
||||
|
||||
vp ->drawingarea ->get_window() ->set_background( vp ->color_fs );
|
||||
vp ->drawingarea ->get_window( ) ->set_background( vp ->color_fs );
|
||||
//eventmasks necessary for tooltips
|
||||
vp ->drawingarea ->add_events( Gdk::ENTER_NOTIFY_MASK );
|
||||
vp ->drawingarea ->add_events( Gdk::LEAVE_NOTIFY_MASK );
|
||||
|
@ -267,25 +273,25 @@ void VBox_VisualDisk::drawingarea_on_realize( Visual_Partition* vp )
|
|||
|
||||
bool VBox_VisualDisk::drawingarea_on_expose( GdkEventExpose * ev, Visual_Partition* vp )
|
||||
{
|
||||
vp ->drawingarea ->get_window() ->clear() ;
|
||||
vp ->drawingarea ->get_window( ) ->clear( ) ;
|
||||
|
||||
if ( vp ->used != -1 ) //if not unknown or unallocated
|
||||
{
|
||||
vp ->gc ->set_foreground( color_used );
|
||||
vp ->drawingarea ->get_window() ->draw_rectangle( vp ->gc, true, BORDER,BORDER, vp ->used, vp ->height );
|
||||
vp ->drawingarea ->get_window( ) ->draw_rectangle( vp ->gc, true, BORDER, BORDER, vp ->used, vp ->height );
|
||||
|
||||
vp ->gc ->set_foreground( color_unused );
|
||||
vp ->drawingarea ->get_window() ->draw_rectangle( vp ->gc, true, BORDER + vp ->used, BORDER, vp ->length - vp ->used - BORDER *2 , vp ->height );
|
||||
vp ->drawingarea ->get_window( ) ->draw_rectangle( vp ->gc, true, BORDER + vp ->used, BORDER, vp ->length - vp ->used - BORDER *2 , vp ->height );
|
||||
}
|
||||
|
||||
vp ->gc ->set_foreground( color_text );
|
||||
vp ->drawingarea ->get_window() ->draw_layout( vp ->gc, BORDER +2, vp ->text_y, vp ->pango_layout ) ;
|
||||
vp ->drawingarea ->get_window( ) ->draw_layout( vp ->gc, BORDER +2, vp ->text_y, vp ->pango_layout ) ;
|
||||
|
||||
//if partition is selected one..
|
||||
if ( vp ->index == selected_partition )
|
||||
{
|
||||
vp ->gc ->set_foreground( color_used );
|
||||
vp ->drawingarea ->get_window() ->draw_rectangle( vp ->gc, false, 4,4,vp ->length-8, vp ->height +8 );
|
||||
vp ->drawingarea ->get_window( ) ->draw_rectangle( vp ->gc, false, 4, 4, vp ->length -8, vp ->height +8 );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -293,24 +299,24 @@ bool VBox_VisualDisk::drawingarea_on_expose( GdkEventExpose * ev, Visual_Partiti
|
|||
|
||||
bool VBox_VisualDisk::on_drawingarea_button_press( GdkEventButton *event, const Partition & partition )
|
||||
{
|
||||
signal_mouse_click.emit( event, partition );
|
||||
signal_mouse_click .emit( event, partition );
|
||||
return true;
|
||||
}
|
||||
|
||||
VBox_VisualDisk::~VBox_VisualDisk()
|
||||
VBox_VisualDisk::~VBox_VisualDisk( )
|
||||
{
|
||||
for ( unsigned int t=0;t< visual_partitions.size() ; t++ )
|
||||
for ( unsigned int t = 0 ; t < visual_partitions .size( ) ; t++ )
|
||||
{
|
||||
this ->get_colormap() ->free_colors( visual_partitions[t] ->color_fs, 1 ) ;
|
||||
delete visual_partitions[t] ;
|
||||
this ->get_colormap( ) ->free_colors( visual_partitions[ t ] ->color_fs, 1 ) ;
|
||||
delete visual_partitions[ t ] ;
|
||||
}
|
||||
|
||||
visual_partitions.clear() ;
|
||||
visual_partitions .clear( ) ;
|
||||
|
||||
//free the allocated colors
|
||||
this ->get_colormap() ->free_colors( color_used, 1 ) ;
|
||||
this ->get_colormap() ->free_colors( color_unused, 1 ) ;
|
||||
this ->get_colormap() ->free_colors( color_text, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_used, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_unused, 1 ) ;
|
||||
this ->get_colormap( ) ->free_colors( color_text, 1 ) ;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -585,7 +585,7 @@ void Win_GParted::Set_Valid_Operations()
|
|||
allow_new( true );
|
||||
|
||||
//find out if there is a copied partition and if it fits inside this unallocated space
|
||||
if ( copied_partition .partition != "NONE" && copied_partition .Get_Length_MB() < selected_partition .Get_Length_MB() )
|
||||
if ( copied_partition .partition != "NONE" && copied_partition .Get_Length_MB( ) < selected_partition .Get_Length_MB( ) )
|
||||
allow_paste( true ) ;
|
||||
|
||||
return ;
|
||||
|
@ -611,7 +611,9 @@ void Win_GParted::Set_Valid_Operations()
|
|||
allow_resize( true ) ;
|
||||
|
||||
//only allow copying of real partitions
|
||||
if ( selected_partition .status != GParted::STAT_NEW && selected_partition .status != GParted::STAT_COPY )
|
||||
if ( selected_partition .status != GParted::STAT_NEW &&
|
||||
selected_partition .status != GParted::STAT_COPY &&
|
||||
Get_FS( selected_partition .filesystem, gparted_core .get_fs( ) ) .copy )
|
||||
allow_copy( true ) ;
|
||||
}
|
||||
|
||||
|
@ -833,13 +835,13 @@ void Win_GParted::activate_resize()
|
|||
|
||||
std::vector <Partition> partitions = devices[ current_device ] .device_partitions ;
|
||||
|
||||
if ( operations.size() )
|
||||
for (unsigned int t=0;t<operations.size();t++ )
|
||||
if ( operations[t]. device_path == devices[ current_device ] .path )
|
||||
if ( operations .size( ) )
|
||||
for (unsigned int t = 0 ; t < operations .size( ) ; t++ )
|
||||
if ( operations[ t ] .device_path == devices[ current_device ] .path )
|
||||
operations[ t ] .Apply_Operation_To_Visual( partitions ) ;
|
||||
|
||||
|
||||
Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( ) ) ;
|
||||
Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( ), devices[ current_device ] .length / devices[ current_device ] .cylinders ) ;
|
||||
|
||||
if ( selected_partition .type == GParted::LOGICAL )
|
||||
{
|
||||
|
|
105
src/ext2.cc
105
src/ext2.cc
|
@ -26,79 +26,67 @@ FS ext2::get_filesystem_support( )
|
|||
FS fs ;
|
||||
|
||||
fs .filesystem = "ext2" ;
|
||||
fs .create = true ;
|
||||
fs .resize = true ;
|
||||
if ( ! system( "which dumpe2fs 1>/dev/null 2>/dev/null" ) )
|
||||
fs .read = true ;
|
||||
|
||||
if ( ! system( "which mkfs.ext2 1>/dev/null 2>/dev/null" ) )
|
||||
fs .create = true ;
|
||||
|
||||
if ( ! system( "which e2fsck 1>/dev/null 2>/dev/null" ) )
|
||||
fs .check = true ;
|
||||
|
||||
//resizing is a delicate process which requires 3 commands..
|
||||
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
|
||||
fs .resize = true ;
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
|
||||
fs .copy = true ;
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
||||
bool ext2::Create( const Glib::ustring device_path, const Partition & new_partition )
|
||||
void ext2::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
bool return_value = false ;
|
||||
char c_buf[ 512 ] ;
|
||||
FILE *f ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
Glib::ustring output ;
|
||||
Sector free_blocks = -1, blocksize = -1 ;
|
||||
|
||||
//get free blocks..
|
||||
f = popen( ( "dumpe2fs -h " + partition .partition ) .c_str( ), "r" ) ;
|
||||
while ( fgets( c_buf, 512, f ) )
|
||||
{
|
||||
PedPartition *c_part = NULL ;
|
||||
PedFileSystemType *fs_type = NULL ;
|
||||
PedFileSystem *fs = NULL ;
|
||||
output = Glib::locale_to_utf8( c_buf ) ;
|
||||
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (new_partition .sector_end + new_partition .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs_type = ped_file_system_type_get( "ext2" ) ;
|
||||
if ( fs_type )
|
||||
{
|
||||
fs = ped_file_system_create( & c_part ->geom, fs_type, NULL );
|
||||
if ( fs )
|
||||
{
|
||||
if ( ped_partition_set_system( c_part, fs_type ) )
|
||||
return_value = Commit( disk ) ;
|
||||
//free blocks
|
||||
if ( output .find( "Free blocks" ) < output .length( ) )
|
||||
free_blocks = atoi( (output .substr( output .find( ":" ) +1, output .length( ) ) ) .c_str( ) ) ;
|
||||
|
||||
ped_file_system_close( fs );
|
||||
}
|
||||
}
|
||||
}
|
||||
//blocksize
|
||||
if ( output .find( "Block size:" ) < output .length( ) )
|
||||
blocksize = atoi( (output .substr( output .find( ":" ) +1, output .length( ) ) ) .c_str( ) ) ;
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
}
|
||||
pclose( f ) ;
|
||||
|
||||
return return_value ;
|
||||
if ( free_blocks > -1 && blocksize > -1 )
|
||||
partition .Set_Unused( free_blocks * blocksize / 512 ) ;
|
||||
}
|
||||
|
||||
bool ext2::Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new )
|
||||
bool ext2::Create( const Glib::ustring device_path, const Partition & new_partition )
|
||||
{
|
||||
bool return_value = false ;
|
||||
return Execute_Command( "mkfs.ext2 " + new_partition .partition ) ;
|
||||
}
|
||||
|
||||
PedPartition *c_part = NULL ;
|
||||
PedFileSystem *fs = NULL ;
|
||||
PedConstraint *constraint = NULL ;
|
||||
bool ext2::Resize( const Partition & partition_new, bool fill_partition )
|
||||
{
|
||||
Glib::ustring str_temp = "resize2fs " + partition_new .partition ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
{
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs = ped_file_system_open ( & c_part->geom );
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs );
|
||||
if ( constraint )
|
||||
{
|
||||
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, partition_new .sector_start, partition_new .sector_end ) &&
|
||||
ped_file_system_resize ( fs, & c_part->geom, NULL ) )
|
||||
return_value = Commit( disk ) ;
|
||||
if ( ! fill_partition )
|
||||
str_temp += " " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_file_system_close ( fs );
|
||||
}
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
}
|
||||
|
||||
return return_value ;
|
||||
return Execute_Command( str_temp ) ;
|
||||
}
|
||||
|
||||
bool ext2::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
|
||||
|
@ -106,9 +94,14 @@ bool ext2::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest
|
|||
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
|
||||
}
|
||||
|
||||
bool ext2::Check_Repair( const Partition & partition )
|
||||
{
|
||||
return Execute_Command( "e2fsck -fy " + partition .partition ) ;
|
||||
}
|
||||
|
||||
int ext2::get_estimated_time( long MB_to_Consider )
|
||||
{
|
||||
return 1 + MB_to_Consider / 500 ;
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
|
||||
|
|
109
src/ext3.cc
109
src/ext3.cc
|
@ -26,89 +26,67 @@ FS ext3::get_filesystem_support( )
|
|||
FS fs ;
|
||||
|
||||
fs .filesystem = "ext3" ;
|
||||
if ( ! system( "which dumpe2fs 1>/dev/null 2>/dev/null" ) )
|
||||
fs .read = true ;
|
||||
|
||||
if ( ! system( "which tune2fs 1>/dev/null 2>/dev/null" ) )
|
||||
if ( ! system( "which mkfs.ext3 1>/dev/null 2>/dev/null" ) )
|
||||
fs .create = true ;
|
||||
|
||||
fs .resize = true ;
|
||||
if ( ! system( "which e2fsck 1>/dev/null 2>/dev/null" ) )
|
||||
fs .check = true ;
|
||||
|
||||
//resizing is a delicate process which requires 3 commands..
|
||||
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
|
||||
fs .resize = true ;
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
|
||||
fs .copy = true ;
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
||||
bool ext3::Create( const Glib::ustring device_path, const Partition & new_partition )
|
||||
void ext3::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
bool return_value = false ;
|
||||
char c_buf[ 512 ] ;
|
||||
FILE *f ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
Glib::ustring output ;
|
||||
Sector free_blocks = -1, blocksize = -1 ;
|
||||
|
||||
//get free blocks..
|
||||
f = popen( ( "dumpe2fs -h " + partition .partition ) .c_str( ), "r" ) ;
|
||||
while ( fgets( c_buf, 512, f ) )
|
||||
{
|
||||
PedPartition *c_part = NULL ;
|
||||
PedFileSystemType *fs_type = NULL ;
|
||||
PedFileSystem *fs = NULL ;
|
||||
output = Glib::locale_to_utf8( c_buf ) ;
|
||||
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (new_partition .sector_end + new_partition .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs_type = ped_file_system_type_get( "ext2" ) ;
|
||||
if ( fs_type )
|
||||
{
|
||||
fs = ped_file_system_create( & c_part ->geom, fs_type, NULL );
|
||||
if ( fs )
|
||||
{
|
||||
if ( ped_partition_set_system(c_part, fs_type ) )
|
||||
{
|
||||
return_value = Commit( disk ) ;
|
||||
//free blocks
|
||||
if ( output .find( "Free blocks" ) < output .length( ) )
|
||||
free_blocks = atoi( (output .substr( output .find( ":" ) +1, output .length( ) ) ) .c_str( ) ) ;
|
||||
|
||||
sleep( 1 ) ;
|
||||
//system( ("tune2fs -j " + new_partition .partition) .c_str( ) ) ;
|
||||
Execute_Command( "tune2fs -j " + new_partition .partition ) ;
|
||||
//blocksize
|
||||
if ( output .find( "Block size:" ) < output .length( ) )
|
||||
blocksize = atoi( (output .substr( output .find( ":" ) +1, output .length( ) ) ) .c_str( ) ) ;
|
||||
|
||||
}
|
||||
|
||||
ped_file_system_close( fs );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk) ;
|
||||
}
|
||||
pclose( f ) ;
|
||||
|
||||
return return_value ;
|
||||
if ( free_blocks > -1 && blocksize > -1 )
|
||||
partition .Set_Unused( free_blocks * blocksize / 512 ) ;
|
||||
}
|
||||
|
||||
bool ext3::Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new )
|
||||
bool ext3::Create( const Glib::ustring device_path, const Partition & new_partition )
|
||||
{
|
||||
bool return_value = false ;
|
||||
return Execute_Command( "mkfs.ext3 " + new_partition .partition ) ;
|
||||
}
|
||||
|
||||
PedPartition *c_part = NULL ;
|
||||
PedFileSystem *fs = NULL ;
|
||||
PedConstraint *constraint = NULL ;
|
||||
bool ext3::Resize( const Partition & partition_new, bool fill_partition )
|
||||
{
|
||||
Glib::ustring str_temp = "resize2fs " + partition_new .partition ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
{
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs = ped_file_system_open ( & c_part->geom );
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs );
|
||||
if ( constraint )
|
||||
{
|
||||
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, partition_new .sector_start, partition_new .sector_end ) &&
|
||||
ped_file_system_resize ( fs, & c_part->geom, NULL ) )
|
||||
return_value = Commit( disk ) ;
|
||||
if ( ! fill_partition )
|
||||
str_temp += " " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_file_system_close ( fs );
|
||||
}
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
}
|
||||
|
||||
return return_value ;
|
||||
return Execute_Command( str_temp ) ;
|
||||
}
|
||||
|
||||
bool ext3::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
|
||||
|
@ -116,9 +94,14 @@ bool ext3::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest
|
|||
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
|
||||
}
|
||||
|
||||
bool ext3::Check_Repair( const Partition & partition )
|
||||
{
|
||||
return Execute_Command( "e2fsck -fy " + partition .partition ) ;
|
||||
}
|
||||
|
||||
int ext3::get_estimated_time( long MB_to_Consider )
|
||||
{
|
||||
return 1 + MB_to_Consider / 400 ;
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
76
src/fat16.cc
76
src/fat16.cc
|
@ -26,13 +26,46 @@ FS fat16::get_filesystem_support( )
|
|||
FS fs ;
|
||||
|
||||
fs .filesystem = "fat16" ;
|
||||
fs .read = true ; //provided by libparted
|
||||
fs .create = true ;
|
||||
fs .resize = true ;
|
||||
fs .move = true ;
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
|
||||
fs .copy = true ;
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
||||
void fat16::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
PedFileSystem *fs = NULL;
|
||||
PedConstraint *constraint = NULL;
|
||||
PedPartition *c_part = NULL ;
|
||||
|
||||
if ( disk )
|
||||
{
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs = ped_file_system_open( & c_part ->geom );
|
||||
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs ) ;
|
||||
if ( constraint )
|
||||
{
|
||||
partition .Set_Unused( (partition .sector_end - partition .sector_start) - constraint ->min_size ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_file_system_close( fs ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool fat16::Create( const Glib::ustring device_path, const Partition & new_partition )
|
||||
{
|
||||
bool return_value = false ;
|
||||
|
@ -66,40 +99,10 @@ bool fat16::Create( const Glib::ustring device_path, const Partition & new_parti
|
|||
return return_value ;
|
||||
}
|
||||
|
||||
bool fat16::Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new )
|
||||
bool fat16::Resize( const Partition & partition_new, bool fill_partition )
|
||||
{
|
||||
bool return_value = false ;
|
||||
|
||||
PedPartition *c_part = NULL ;
|
||||
PedFileSystem *fs = NULL ;
|
||||
PedConstraint *constraint = NULL ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
{
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs = ped_file_system_open ( & c_part->geom );
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs );
|
||||
if ( constraint )
|
||||
{
|
||||
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, partition_new .sector_start, partition_new .sector_end ) &&
|
||||
ped_file_system_resize ( fs, & c_part->geom, NULL ) )
|
||||
return_value = Commit( disk ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_file_system_close ( fs );
|
||||
}
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk) ;
|
||||
}
|
||||
|
||||
return return_value ;
|
||||
//handled in GParted_Core::Resize_Normal_Using_Libparted
|
||||
return false ;
|
||||
}
|
||||
|
||||
bool fat16::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
|
||||
|
@ -107,9 +110,14 @@ bool fat16::Copy( const Glib::ustring & src_part_path, const Glib::ustring & des
|
|||
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
|
||||
}
|
||||
|
||||
bool fat16::Check_Repair( const Partition & partition )
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
int fat16::get_estimated_time( long MB_to_Consider )
|
||||
{
|
||||
return 1 ;
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
76
src/fat32.cc
76
src/fat32.cc
|
@ -26,6 +26,7 @@ FS fat32::get_filesystem_support( )
|
|||
FS fs ;
|
||||
|
||||
fs .filesystem = "fat32" ;
|
||||
fs .read = true ; //provided by libparted
|
||||
|
||||
//find out if we can create fat32 filesystems
|
||||
if ( ! system( "which mkdosfs 1>/dev/null 2>/dev/null" ) )
|
||||
|
@ -35,48 +36,50 @@ FS fat32::get_filesystem_support( )
|
|||
fs .resize = true ;
|
||||
fs .move = true ;
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
|
||||
fs .copy = true ;
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
||||
void fat32::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
PedFileSystem *fs = NULL;
|
||||
PedConstraint *constraint = NULL;
|
||||
PedPartition *c_part = NULL ;
|
||||
|
||||
if ( disk )
|
||||
{
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs = ped_file_system_open( & c_part ->geom );
|
||||
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs ) ;
|
||||
if ( constraint )
|
||||
{
|
||||
partition .Set_Unused( (partition .sector_end - partition .sector_start) - constraint ->min_size ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_file_system_close( fs ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool fat32::Create( const Glib::ustring device_path, const Partition & new_partition )
|
||||
{
|
||||
return Execute_Command( "mkdosfs -F32 " + new_partition .partition ) ;
|
||||
}
|
||||
|
||||
bool fat32::Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new )
|
||||
bool fat32::Resize( const Partition & partition_new, bool fill_partition )
|
||||
{
|
||||
bool return_value = false ;
|
||||
|
||||
PedPartition *c_part = NULL ;
|
||||
PedFileSystem *fs = NULL ;
|
||||
PedConstraint *constraint = NULL ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
{
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs = ped_file_system_open ( & c_part->geom );
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs );
|
||||
if ( constraint )
|
||||
{
|
||||
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, partition_new .sector_start, partition_new .sector_end ) &&
|
||||
ped_file_system_resize ( fs, & c_part->geom, NULL ) )
|
||||
return_value = Commit( disk ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_file_system_close ( fs );
|
||||
}
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk) ;
|
||||
}
|
||||
|
||||
return return_value ;
|
||||
//handled in GParted_Core::Resize_Normal_Using_Libparted
|
||||
return false ;
|
||||
}
|
||||
|
||||
bool fat32::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
|
||||
|
@ -84,9 +87,14 @@ bool fat32::Copy( const Glib::ustring & src_part_path, const Glib::ustring & des
|
|||
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
|
||||
}
|
||||
|
||||
bool fat32::Check_Repair( const Partition & partition )
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
int fat32::get_estimated_time( long MB_to_Consider )
|
||||
{
|
||||
return 1 + MB_to_Consider / 5000 ;
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,13 +26,21 @@ FS linux_swap::get_filesystem_support( )
|
|||
FS fs ;
|
||||
|
||||
fs .filesystem = "linux-swap" ;
|
||||
fs .read = false ; //used/unused isn't relevant for swapspace
|
||||
fs .create = true ;
|
||||
fs .resize = true ;
|
||||
fs .move = true ;
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
|
||||
fs .copy = true ;
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
||||
void linux_swap::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
}
|
||||
|
||||
bool linux_swap::Create( const Glib::ustring device_path, const Partition & new_partition )
|
||||
{
|
||||
bool return_value = false ;
|
||||
|
@ -66,40 +74,10 @@ bool linux_swap::Create( const Glib::ustring device_path, const Partition & new_
|
|||
return return_value ;
|
||||
}
|
||||
|
||||
bool linux_swap::Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new )
|
||||
bool linux_swap::Resize( const Partition & partition_new, bool fill_partition )
|
||||
{
|
||||
bool return_value = false ;
|
||||
|
||||
PedPartition *c_part = NULL ;
|
||||
PedFileSystem *fs = NULL ;
|
||||
PedConstraint *constraint = NULL ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
{
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs = ped_file_system_open ( & c_part->geom );
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs );
|
||||
if ( constraint )
|
||||
{
|
||||
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, partition_new .sector_start, partition_new .sector_end ) &&
|
||||
ped_file_system_resize ( fs, & c_part->geom, NULL ) )
|
||||
return_value = Commit( disk ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_file_system_close ( fs );
|
||||
}
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
}
|
||||
|
||||
return return_value ;
|
||||
//handled in GParted_Core::Resize_Normal_Using_Libparted
|
||||
return false ;
|
||||
}
|
||||
|
||||
bool linux_swap::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
|
||||
|
@ -107,6 +85,11 @@ bool linux_swap::Copy( const Glib::ustring & src_part_path, const Glib::ustring
|
|||
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
|
||||
}
|
||||
|
||||
bool linux_swap::Check_Repair( const Partition & partition )
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
int linux_swap::get_estimated_time( long MB_to_Consider )
|
||||
{
|
||||
return 1 + MB_to_Consider / 5000 ;
|
||||
|
|
|
@ -30,6 +30,7 @@ FS reiserfs::get_filesystem_support( )
|
|||
static void * test_handle = NULL ;
|
||||
if ( (test_handle = dlopen("libreiserfs.so", RTLD_NOW)) )
|
||||
{
|
||||
fs .read = true ;
|
||||
fs .create = true ;
|
||||
fs .resize = true ;
|
||||
|
||||
|
@ -37,9 +38,41 @@ FS reiserfs::get_filesystem_support( )
|
|||
test_handle = NULL ;
|
||||
}
|
||||
|
||||
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
|
||||
fs .copy = true ;
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
||||
void reiserfs::Set_Used_Sectors( Partition & partition )
|
||||
{
|
||||
PedFileSystem *fs = NULL;
|
||||
PedConstraint *constraint = NULL;
|
||||
PedPartition *c_part = NULL ;
|
||||
|
||||
if ( disk )
|
||||
{
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs = ped_file_system_open( & c_part ->geom );
|
||||
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs ) ;
|
||||
if ( constraint )
|
||||
{
|
||||
partition .Set_Unused( (partition .sector_end - partition .sector_start) - constraint ->min_size ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_file_system_close( fs ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool reiserfs::Create( const Glib::ustring device_path, const Partition & new_partition )
|
||||
{
|
||||
bool return_value = false ;
|
||||
|
@ -73,40 +106,9 @@ bool reiserfs::Create( const Glib::ustring device_path, const Partition & new_pa
|
|||
return return_value ;
|
||||
}
|
||||
|
||||
bool reiserfs::Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new )
|
||||
bool reiserfs::Resize( const Partition & partition_new, bool fill_partition )
|
||||
{
|
||||
bool return_value = false ;
|
||||
|
||||
PedPartition *c_part = NULL ;
|
||||
PedFileSystem *fs = NULL ;
|
||||
PedConstraint *constraint = NULL ;
|
||||
|
||||
if ( open_device_and_disk( device_path, device, disk ) )
|
||||
{
|
||||
c_part = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
|
||||
if ( c_part )
|
||||
{
|
||||
fs = ped_file_system_open ( & c_part->geom );
|
||||
if ( fs )
|
||||
{
|
||||
constraint = ped_file_system_get_resize_constraint ( fs );
|
||||
if ( constraint )
|
||||
{
|
||||
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, partition_new .sector_start, partition_new .sector_end ) &&
|
||||
ped_file_system_resize ( fs, & c_part->geom, NULL ) )
|
||||
return_value = Commit( disk ) ;
|
||||
|
||||
ped_constraint_destroy ( constraint );
|
||||
}
|
||||
|
||||
ped_file_system_close ( fs );
|
||||
}
|
||||
}
|
||||
|
||||
close_device_and_disk( device, disk ) ;
|
||||
}
|
||||
|
||||
return return_value ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
bool reiserfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
|
||||
|
@ -114,6 +116,11 @@ bool reiserfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring &
|
|||
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
|
||||
}
|
||||
|
||||
bool reiserfs::Check_Repair( const Partition & partition )
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
int reiserfs::get_estimated_time( long MB_to_Consider )
|
||||
{
|
||||
return 1 + MB_to_Consider / 1000 ;
|
||||
|
|
Loading…
Reference in New Issue