implemented snap to cylinder algorithm. Although the algorithm is very
* src/Win_GParted.cc, include/GParted_Core.h, src/GParted_Core.cc: implemented snap to cylinder algorithm. Although the algorithm is very simple, it seems to work perfectly. However, some additional testing is required.
This commit is contained in:
parent
37bb7bb4a6
commit
8c5326e8b6
|
@ -1,3 +1,11 @@
|
||||||
|
2006-07-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
|
* src/Win_GParted.cc,
|
||||||
|
include/GParted_Core.h,
|
||||||
|
src/GParted_Core.cc: implemented snap to cylinder algorithm.
|
||||||
|
Although the algorithm is very simple, it seems to work perfectly.
|
||||||
|
However, some additional testing is required.
|
||||||
|
|
||||||
2006-07-11 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
2006-07-11 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
* lots of fixes and improvements (mostly move-related)
|
* lots of fixes and improvements (mostly move-related)
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
void set_user_devices( const std::vector<Glib::ustring> & user_devices ) ;
|
void set_user_devices( const std::vector<Glib::ustring> & user_devices ) ;
|
||||||
void set_devices( std::vector<Device> & devices ) ;
|
void set_devices( std::vector<Device> & devices ) ;
|
||||||
|
|
||||||
bool snap_to_cylinder( Partition & partition ) ;
|
bool snap_to_cylinder( const Device & device, Partition & partition ) ;
|
||||||
bool apply_operation_to_disk( Operation * operation );
|
bool apply_operation_to_disk( Operation * operation );
|
||||||
|
|
||||||
bool set_disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ;
|
bool set_disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ;
|
||||||
|
|
|
@ -229,9 +229,40 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
|
||||||
fstab_info .clear() ;
|
fstab_info .clear() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GParted_Core::snap_to_cylinder( Partition & partition )
|
bool GParted_Core::snap_to_cylinder( const Device & device, Partition & partition )
|
||||||
{
|
{
|
||||||
//FIXME: insert here basicly the functionality of snap_to_boundaries from parted.c
|
if ( ! partition .strict )
|
||||||
|
{
|
||||||
|
Sector diff = partition .sector_start % device .cylsize ;
|
||||||
|
if ( diff )
|
||||||
|
{
|
||||||
|
if ( diff < ( device .cylsize / 2 ) )
|
||||||
|
partition .sector_start -= diff ;
|
||||||
|
else
|
||||||
|
partition .sector_start += (device .cylsize - diff ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff = (partition .sector_end +1) % device .cylsize ;
|
||||||
|
if ( diff )
|
||||||
|
{
|
||||||
|
if ( diff < ( device .cylsize / 2 ) )
|
||||||
|
partition .sector_end -= diff ;
|
||||||
|
else
|
||||||
|
partition .sector_end += (device .cylsize - diff ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( partition .sector_start < 0 )
|
||||||
|
partition .sector_start = 0 ;
|
||||||
|
if ( partition .sector_end > device .length )
|
||||||
|
partition .sector_end = device .length -1 ;
|
||||||
|
|
||||||
|
//FIXME: it would be perfect if we could check for overlapping with adjacent partitions as well,
|
||||||
|
//however, finding the adjacent partitions is not as easy as it seems and at this moment all the dialogs
|
||||||
|
//already perform these checks. A perfect 'fixme-later' ;)
|
||||||
|
|
||||||
|
//FIXME: what kind of errorchecking could we do here? maybe checking if partitionlenght > used?
|
||||||
|
}
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -617,7 +617,7 @@ void Win_GParted::Add_Operation( OperationType operationtype,
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: do this in two separate steps and be more verbose in case of error..
|
//FIXME: do this in two separate steps and be more verbose in case of error..
|
||||||
if ( operation && gparted_core .snap_to_cylinder( operation ->partition_new ) )
|
if ( operation && gparted_core .snap_to_cylinder( operation ->device, operation ->partition_new ) )
|
||||||
{
|
{
|
||||||
operation ->create_description() ;
|
operation ->create_description() ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue