check if dest >= src before starting a copy
* include/GParted_Core.h, src/GParted_Core.cc: check if dest >= src before starting a copy
This commit is contained in:
parent
e0c354880a
commit
9cbfca1c6e
|
@ -1,3 +1,8 @@
|
||||||
|
2006-09-03 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
|
* include/GParted_Core.h,
|
||||||
|
src/GParted_Core.cc: check if dest >= src before starting a copy
|
||||||
|
|
||||||
2006-09-03 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
2006-09-03 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
* src/GParted_Core.cc: fixed an issue with copying to unallocated
|
* src/GParted_Core.cc: fixed an issue with copying to unallocated
|
||||||
|
|
|
@ -106,7 +106,7 @@ private:
|
||||||
bool maximize_filesystem( const Partition & partition, OperationDetail & operationdetail ) ;
|
bool maximize_filesystem( const Partition & partition, OperationDetail & operationdetail ) ;
|
||||||
|
|
||||||
bool copy( const Partition & partition_src,
|
bool copy( const Partition & partition_src,
|
||||||
Partition & partition_dest,
|
Partition & partition_dst,
|
||||||
Sector min_size,
|
Sector min_size,
|
||||||
OperationDetail & operationdetail ) ;
|
OperationDetail & operationdetail ) ;
|
||||||
bool copy_filesystem( const Partition & partition_src,
|
bool copy_filesystem( const Partition & partition_src,
|
||||||
|
|
|
@ -1439,28 +1439,36 @@ bool GParted_Core::maximize_filesystem( const Partition & partition, OperationDe
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GParted_Core::copy( const Partition & partition_src,
|
bool GParted_Core::copy( const Partition & partition_src,
|
||||||
Partition & partition_dest,
|
Partition & partition_dst,
|
||||||
Sector min_size,
|
Sector min_size,
|
||||||
OperationDetail & operationdetail )
|
OperationDetail & operationdetail )
|
||||||
{//FIXME: add a check to see if dest >= src...
|
{
|
||||||
|
if ( partition_dst .get_length() < partition_src .get_length() )
|
||||||
|
{
|
||||||
|
operationdetail .add_child( OperationDetail(
|
||||||
|
_("the destination is smaller than the sourcepartition"), STATUS_ERROR, FONT_ITALIC ) ) ;
|
||||||
|
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
if ( check_repair_filesystem( partition_src, operationdetail ) )
|
if ( check_repair_filesystem( partition_src, operationdetail ) )
|
||||||
{
|
{
|
||||||
bool succes = true ;
|
bool succes = true ;
|
||||||
if ( partition_dest .status == GParted::STAT_COPY )
|
if ( partition_dst .status == GParted::STAT_COPY )
|
||||||
succes = create_partition( partition_dest, operationdetail, min_size ) ;
|
succes = create_partition( partition_dst, operationdetail, min_size ) ;
|
||||||
|
|
||||||
if ( succes && set_partition_type( partition_dest, operationdetail ) )
|
if ( succes && set_partition_type( partition_dst, operationdetail ) )
|
||||||
{
|
{
|
||||||
operationdetail .add_child( OperationDetail(
|
operationdetail .add_child( OperationDetail(
|
||||||
String::ucompose( _("copy filesystem of %1 to %2"),
|
String::ucompose( _("copy filesystem of %1 to %2"),
|
||||||
partition_src .get_path(),
|
partition_src .get_path(),
|
||||||
partition_dest .get_path() ) ) ) ;
|
partition_dst .get_path() ) ) ) ;
|
||||||
|
|
||||||
switch ( get_fs( partition_dest .filesystem ) .copy )
|
switch ( get_fs( partition_dst .filesystem ) .copy )
|
||||||
{
|
{
|
||||||
case GParted::FS::GPARTED :
|
case GParted::FS::GPARTED :
|
||||||
succes = copy_filesystem( partition_src,
|
succes = copy_filesystem( partition_src,
|
||||||
partition_dest,
|
partition_dst,
|
||||||
operationdetail .get_last_child() ) ;
|
operationdetail .get_last_child() ) ;
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
|
@ -1469,9 +1477,9 @@ bool GParted_Core::copy( const Partition & partition_src,
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case GParted::FS::EXTERNAL :
|
case GParted::FS::EXTERNAL :
|
||||||
succes = set_proper_filesystem( partition_dest .filesystem ) &&
|
succes = set_proper_filesystem( partition_dst .filesystem ) &&
|
||||||
p_filesystem ->copy( partition_src .get_path(),
|
p_filesystem ->copy( partition_src .get_path(),
|
||||||
partition_dest .get_path(),
|
partition_dst .get_path(),
|
||||||
operationdetail .get_last_child() ) ;
|
operationdetail .get_last_child() ) ;
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
|
@ -1483,8 +1491,8 @@ bool GParted_Core::copy( const Partition & partition_src,
|
||||||
operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
|
operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
|
||||||
|
|
||||||
return ( succes &&
|
return ( succes &&
|
||||||
check_repair_filesystem( partition_dest, operationdetail ) &&
|
check_repair_filesystem( partition_dst, operationdetail ) &&
|
||||||
maximize_filesystem( partition_dest, operationdetail ) ) ;
|
maximize_filesystem( partition_dst, operationdetail ) ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue