fixed issues with copying (see also #335004) cleanups + added FIXME added
* include/GParted_Core.h, src/GParted_Core.cc, src/Win_GParted.cc, src/ext2.cc, src/ext3.cc, src/fat16.cc, src/fat32.cc, src/jfs.cc, src/ntfs.cc, src/reiserfs.cc: fixed issues with copying (see also #335004) * include/Operation.h, src/Operation.cc: cleanups + added FIXME * include/Partition.h, src/Partition.cc: added clear_mountpoints() * src/DrawingAreaVisualDisk.cc: added FIXME
This commit is contained in:
parent
4e57356c34
commit
ad9f2126e7
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2006-03-19 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/GParted_Core.h,
|
||||
src/GParted_Core.cc,
|
||||
src/Win_GParted.cc,
|
||||
src/ext2.cc,
|
||||
src/ext3.cc,
|
||||
src/fat16.cc,
|
||||
src/fat32.cc,
|
||||
src/jfs.cc,
|
||||
src/ntfs.cc,
|
||||
src/reiserfs.cc: fixed issues with copying (see also #335004)
|
||||
* include/Operation.h,
|
||||
src/Operation.cc: cleanups + added FIXME
|
||||
* include/Partition.h,
|
||||
src/Partition.cc: added clear_mountpoints()
|
||||
* src/DrawingAreaVisualDisk.cc: added FIXME
|
||||
|
||||
2006-03-18 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/DrawingAreaVisualDisk.h,
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
std::vector<OperationDetails> & operation_detail ) ;
|
||||
bool copy( const Glib::ustring & src_part_path,
|
||||
Partition & partition_dest,
|
||||
Sector min_size,
|
||||
std::vector<OperationDetails> & operation_details ) ;
|
||||
|
||||
bool Set_Disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ;
|
||||
|
@ -88,14 +89,14 @@ private:
|
|||
void set_flags( Partition & partition ) ;
|
||||
int create_empty_partition( Partition & new_partition,
|
||||
std::vector<OperationDetails> & operation_details,
|
||||
bool copy = false ) ;
|
||||
Sector min_size = 0 ) ;
|
||||
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 ) ;
|
||||
std::vector<OperationDetails> & operation_details ) ;
|
||||
|
||||
void set_proper_filesystem( const FILESYSTEM & filesystem ) ;
|
||||
bool set_partition_type( const Partition & partition,
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define OPERATION
|
||||
|
||||
#include "../include/Device.h"
|
||||
|
||||
//FIXME: i guess it's better to split Operation in several (sub)classes for increased efficiency/clearity
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
|
@ -64,7 +64,8 @@ public:
|
|||
Operation() ;
|
||||
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.
|
||||
//this new list can be used to change the visual representation. For real writing to disk, see Apply_To_Disk()
|
||||
void Apply_Operation_To_Visual( std::vector<Partition> & partitions );
|
||||
|
||||
|
@ -75,7 +76,9 @@ public:
|
|||
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.... )
|
||||
Glib::ustring str_operation ;
|
||||
Glib::ustring copied_partition_path ; //for copy operation..
|
||||
|
||||
//for copy operation..
|
||||
Glib::ustring copied_partition_path ;
|
||||
|
||||
OperationDetails operation_details ;
|
||||
|
||||
|
@ -89,7 +92,7 @@ private:
|
|||
void Apply_Resize_Move_To_Visual( std::vector<Partition> & partitions );
|
||||
void Apply_Resize_Move_Extended_To_Visual( std::vector<Partition> & partitions );
|
||||
|
||||
Glib::ustring Get_String( ); //only used in c'tor
|
||||
Glib::ustring Get_String(); //only used in c'tor
|
||||
};
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
std::vector<Glib::ustring> get_paths() const ;
|
||||
void add_mountpoints( const std::vector<Glib::ustring> & mountpoints, bool clear_mountpoints = false ) ;
|
||||
Glib::ustring get_mountpoint() const ;
|
||||
void clear_mountpoints() ;
|
||||
std::vector<Glib::ustring> get_mountpoints() const ;
|
||||
|
||||
bool operator==( const Partition & partition ) const ;
|
||||
|
|
|
@ -343,7 +343,8 @@ bool DrawingAreaVisualDisk::on_button_press_event( GdkEventButton * event )
|
|||
|
||||
signal_partition_selected .emit( selected_vp .partition, false ) ;
|
||||
|
||||
if ( event ->type == GDK_2BUTTON_PRESS )
|
||||
if ( event ->type == GDK_2BUTTON_PRESS ) //FIXME: only emit the signal if a partition was selected
|
||||
//right now it's possible to 'activate' a seperator.
|
||||
signal_partition_activated .emit() ;
|
||||
else if ( event ->button == 3 )
|
||||
signal_popup_menu .emit( event ->button, event ->time ) ;
|
||||
|
|
|
@ -562,7 +562,8 @@ bool GParted_Core::apply_operation_to_disk( Operation & operation )
|
|||
case COPY:
|
||||
return copy( operation .copied_partition_path,
|
||||
operation .partition_new,
|
||||
operation .operation_details .sub_details ) ;
|
||||
operation .partition_new .get_length() - operation .device .cylsize,
|
||||
operation .operation_details .sub_details ) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
|
@ -577,10 +578,7 @@ bool GParted_Core::create( const Device & device,
|
|||
{
|
||||
return create_empty_partition( new_partition, operation_details ) ;
|
||||
}
|
||||
else if ( create_empty_partition(
|
||||
new_partition,
|
||||
operation_details,
|
||||
( new_partition .get_length() - device .cylsize ) < get_fs( new_partition .filesystem ) .MIN * MEBIBYTE ) > 0 )
|
||||
else if ( create_empty_partition( new_partition, operation_details, get_fs( new_partition .filesystem ) .MIN ) )
|
||||
{
|
||||
set_proper_filesystem( new_partition .filesystem ) ;
|
||||
|
||||
|
@ -693,16 +691,19 @@ bool GParted_Core::resize( const Device & device,
|
|||
|
||||
bool GParted_Core::copy( const Glib::ustring & src_part_path,
|
||||
Partition & partition_dest,
|
||||
Sector min_size,
|
||||
std::vector<OperationDetails> & operation_details )
|
||||
{
|
||||
set_proper_filesystem( partition_dest .filesystem ) ;
|
||||
Partition src_partition( src_part_path ) ;
|
||||
|
||||
//FIXME: some filesystems (e.g. fat*) can be copied using libparted..
|
||||
return ( p_filesystem &&
|
||||
p_filesystem ->Check_Repair( src_partition, operation_details ) &&
|
||||
create_empty_partition( partition_dest, operation_details, true ) > 0 &&
|
||||
create_empty_partition( partition_dest, operation_details, min_size ) > 0 &&
|
||||
set_partition_type( partition_dest, operation_details ) &&
|
||||
p_filesystem ->Copy( src_part_path, partition_dest .get_path(), operation_details ) &&
|
||||
p_filesystem ->Check_Repair( partition_dest, operation_details ) &&
|
||||
p_filesystem ->Resize( partition_dest, operation_details, true ) &&
|
||||
p_filesystem ->Check_Repair( partition_dest, operation_details ) ) ;
|
||||
}
|
||||
|
||||
|
@ -800,7 +801,7 @@ void GParted_Core::LP_Set_Used_Sectors( Partition & partition )
|
|||
|
||||
int GParted_Core::create_empty_partition( Partition & new_partition,
|
||||
std::vector<OperationDetails> & operation_details,
|
||||
bool copy )
|
||||
Sector min_size )
|
||||
{
|
||||
operation_details .push_back( OperationDetails( _("create empty partition") ) ) ;
|
||||
|
||||
|
@ -852,10 +853,8 @@ int GParted_Core::create_empty_partition( Partition & new_partition,
|
|||
|
||||
if ( constraint )
|
||||
{
|
||||
//FIXME: i should use the length of the copied partition as min_size
|
||||
//maybe we can set the used from new_partition to this size?
|
||||
if ( copy )
|
||||
constraint ->min_size = new_partition .get_length() ;
|
||||
if ( min_size > 0 )
|
||||
constraint ->min_size = min_size ;
|
||||
|
||||
if ( ped_disk_add_partition( lp_disk, lp_partition, constraint ) && commit() )
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ Operation::Operation( const Device & device,
|
|||
}
|
||||
}
|
||||
|
||||
Glib::ustring Operation::Get_String( )
|
||||
Glib::ustring Operation::Get_String()
|
||||
{
|
||||
Glib::ustring temp ;
|
||||
Sector diff ;
|
||||
|
@ -161,7 +161,7 @@ void Operation::Insert_Unallocated( std::vector<Partition> & partitions, Sector
|
|||
UNALLOCATED .Set_Unallocated( device .get_path(), 0, 0, inside_extended ) ;
|
||||
|
||||
//if there are no partitions at all..
|
||||
if ( partitions .empty( ) )
|
||||
if ( partitions .empty() )
|
||||
{
|
||||
UNALLOCATED .sector_start = start ;
|
||||
UNALLOCATED .sector_end = end ;
|
||||
|
@ -172,28 +172,28 @@ void Operation::Insert_Unallocated( std::vector<Partition> & partitions, Sector
|
|||
}
|
||||
|
||||
//start <---> first partition start
|
||||
if ( (partitions .front( ) .sector_start - start) >= MEBIBYTE )
|
||||
if ( (partitions .front() .sector_start - start) >= MEBIBYTE )
|
||||
{
|
||||
UNALLOCATED .sector_start = start ;
|
||||
UNALLOCATED .sector_end = partitions .front( ) .sector_start -1 ;
|
||||
UNALLOCATED .sector_end = partitions .front() .sector_start -1 ;
|
||||
|
||||
partitions .insert( partitions .begin( ), UNALLOCATED );
|
||||
partitions .insert( partitions .begin(), UNALLOCATED );
|
||||
}
|
||||
|
||||
//look for gaps in between
|
||||
for ( unsigned int t =0 ; t < partitions .size( ) -1 ; t++ )
|
||||
for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
|
||||
if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= MEBIBYTE )
|
||||
{
|
||||
UNALLOCATED .sector_start = partitions[ t ] .sector_end +1 ;
|
||||
UNALLOCATED .sector_end = partitions[ t +1 ] .sector_start -1 ;
|
||||
|
||||
partitions .insert( partitions .begin( ) + ++t, UNALLOCATED );
|
||||
partitions .insert( partitions .begin() + ++t, UNALLOCATED );
|
||||
}
|
||||
|
||||
//last partition end <---> end
|
||||
if ( (end - partitions .back( ) .sector_end ) >= MEBIBYTE )
|
||||
if ( (end - partitions .back() .sector_end ) >= MEBIBYTE )
|
||||
{
|
||||
UNALLOCATED .sector_start = partitions .back( ) .sector_end +1 ;
|
||||
UNALLOCATED .sector_start = partitions .back() .sector_end +1 ;
|
||||
UNALLOCATED .sector_end = end ;
|
||||
|
||||
partitions .push_back( UNALLOCATED );
|
||||
|
@ -202,16 +202,18 @@ void Operation::Insert_Unallocated( std::vector<Partition> & partitions, Sector
|
|||
|
||||
int Operation::Get_Index_Original( std::vector<Partition> & partitions )
|
||||
{
|
||||
for ( int t = 0 ; t < static_cast<int>( partitions .size( ) ) ; t++ )
|
||||
if ( partition_original .sector_start >= partitions[ t ] .sector_start && partition_original .sector_end <= partitions[ t ] .sector_end )
|
||||
for ( int t = 0 ; t < static_cast<int>( partitions .size() ) ; t++ )
|
||||
if ( partition_original .sector_start >= partitions[ t ] .sector_start &&
|
||||
partition_original .sector_end <= partitions[ t ] .sector_end )
|
||||
{
|
||||
//remove unallocated space preceding the original partition
|
||||
if ( t -1 >= 0 && partitions[ t -1 ] .type == GParted::TYPE_UNALLOCATED )
|
||||
partitions .erase( partitions .begin( ) + --t );
|
||||
partitions .erase( partitions .begin() + --t );
|
||||
|
||||
//remove unallocated space following the original partition
|
||||
if ( t +1 < static_cast<int>( partitions .size( ) ) && partitions[ t +1 ] .type == GParted::TYPE_UNALLOCATED )
|
||||
partitions .erase( partitions .begin( ) + t +1 );
|
||||
if ( t +1 < static_cast<int>( partitions .size() ) &&
|
||||
partitions[ t +1 ] .type == GParted::TYPE_UNALLOCATED )
|
||||
partitions .erase( partitions .begin() + t +1 );
|
||||
|
||||
return t ;
|
||||
}
|
||||
|
@ -232,14 +234,14 @@ void Operation::Apply_Delete_To_Visual( std::vector<Partition> & partitions )
|
|||
{
|
||||
if ( ! partition_original .inside_extended )
|
||||
{
|
||||
partitions .erase( partitions .begin( ) + Get_Index_Original( partitions ) );
|
||||
partitions .erase( partitions .begin() + Get_Index_Original( partitions ) );
|
||||
|
||||
Insert_Unallocated( partitions, 0, device .length -1, false ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int ext = get_index_extended( partitions ) ;
|
||||
partitions[ ext ] .logicals .erase( partitions[ ext ] .logicals .begin( ) + Get_Index_Original( partitions[ ext ] .logicals ) );
|
||||
partitions[ ext ] .logicals .erase( partitions[ ext ] .logicals .begin() + Get_Index_Original( partitions[ ext ] .logicals ) );
|
||||
|
||||
//if deleted partition was logical we have to decrease the partitionnumbers of the logicals
|
||||
//with higher numbers by one (only if its a real partition)
|
||||
|
|
|
@ -193,6 +193,11 @@ std::vector<Glib::ustring> Partition::get_mountpoints() const
|
|||
return mountpoints ;
|
||||
}
|
||||
|
||||
void Partition::clear_mountpoints()
|
||||
{
|
||||
mountpoints .clear() ;
|
||||
}
|
||||
|
||||
bool Partition::compare_paths( const Glib::ustring & A, const Glib::ustring & B )
|
||||
{
|
||||
return A .length() < B .length() ;
|
||||
|
|
|
@ -1178,8 +1178,9 @@ void Win_GParted::activate_paste()
|
|||
{
|
||||
Dialog_Partition_Copy dialog( gparted_core .get_fs( copied_partition .filesystem ),
|
||||
devices[ current_device ] .cylsize ) ;
|
||||
//we don't need the errors of the source partition.
|
||||
//we don't need the errors/mountpoints of the source partition.
|
||||
copied_partition .error .clear() ;
|
||||
copied_partition .clear_mountpoints() ;
|
||||
dialog .Set_Data( selected_partition, copied_partition ) ;
|
||||
dialog .set_transient_for( *this );
|
||||
|
||||
|
|
11
src/ext2.cc
11
src/ext2.cc
|
@ -126,12 +126,13 @@ bool ext2::Copy( const Glib::ustring & src_part_path,
|
|||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
return Resize( Partition( dest_part_path ), operation_details, true ) ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
bool ext2::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
|
|
11
src/ext3.cc
11
src/ext3.cc
|
@ -127,12 +127,13 @@ bool ext3::Copy( const Glib::ustring & src_part_path,
|
|||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
return Resize( Partition( dest_part_path ), operation_details, true ) ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
bool ext3::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
|
|
|
@ -96,8 +96,7 @@ bool fat16::Resize( const Partition & partition_new,
|
|||
std::vector<OperationDetails> & operation_details,
|
||||
bool fill_partition )
|
||||
{
|
||||
//handled in GParted_Core::resize_normal_using_libparted
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool fat16::Copy( const Glib::ustring & src_part_path,
|
||||
|
|
|
@ -95,8 +95,7 @@ bool fat32::Resize( const Partition & partition_new,
|
|||
std::vector<OperationDetails> & operation_details,
|
||||
bool fill_partition )
|
||||
{
|
||||
//handled in GParted_Core::Resize_Normal_Using_Libparted
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool fat32::Copy( const Glib::ustring & src_part_path,
|
||||
|
|
10
src/jfs.cc
10
src/jfs.cc
|
@ -210,12 +210,14 @@ bool jfs::Copy( const Glib::ustring & src_part_path,
|
|||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
return true ;
|
||||
|
||||
return Resize( Partition( dest_part_path ), operation_details, true ) ;
|
||||
}
|
||||
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
bool jfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
|
|
11
src/ntfs.cc
11
src/ntfs.cc
|
@ -145,12 +145,13 @@ bool ntfs::Copy( const Glib::ustring & src_part_path,
|
|||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
return Resize( Partition( dest_part_path ), operation_details, true ) ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
bool ntfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
|
|
|
@ -133,12 +133,13 @@ bool reiserfs::Copy( const Glib::ustring & src_part_path,
|
|||
operation_details .back() .sub_details ) )
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
return Resize( Partition( dest_part_path ), operation_details, true ) ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
bool reiserfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
|
||||
|
|
Loading…
Reference in New Issue