[gparted] Name partitions as required when creating a new partition (#746214)



commit 8d005aff1a33186df2bffa09e9fc6032fdac785e
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Tue Mar 17 21:57:12 2015 +0000

    Name partitions as required when creating a new partition (#746214)
    
    When the partition is named in the Create New Partition dialog, set the
    partition name as part of the create partition operation.  Currently
    this is only supported for GPTs.  See
    Utils::get_max_partition_name_length() for details.
    
    Bug 746214 - Partition naming enhancements

 src/GParted_Core.cc |   39 ++++++++++++++++++++++++++-------------
 1 files changed, 26 insertions(+), 13 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index f4998b1..77438be 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1961,23 +1961,36 @@ void GParted_Core::set_flags( Partition & partition, PedPartition* lp_partition
 
 bool GParted_Core::create( Partition & new_partition, OperationDetail & operationdetail )
 {
-       if ( new_partition .type == GParted::TYPE_EXTENDED )   
+       bool success;
+       if ( new_partition.type == TYPE_EXTENDED )
        {
-               return create_partition( new_partition, operationdetail ) ;
+               success = create_partition( new_partition, operationdetail );
        }
-       else if ( create_partition( new_partition, operationdetail, (get_fs( new_partition .filesystem ) .MIN 
/ new_partition .sector_size) ) )
+       else
        {
-               if ( new_partition .filesystem == GParted::FS_UNFORMATTED )
-                       return true ;
-               else if ( new_partition .filesystem == FS_CLEARED )
-                       return erase_filesystem_signatures( new_partition, operationdetail ) ;
-               else
-                       return    erase_filesystem_signatures( new_partition, operationdetail )
-                              && set_partition_type( new_partition, operationdetail )
-                              && create_filesystem( new_partition, operationdetail ) ;
+               success = create_partition( new_partition, operationdetail,
+                                           get_fs( new_partition.filesystem ).MIN / 
new_partition.sector_size );
        }
-       
-       return false ;
+       if ( ! success )
+               return false;
+
+       if ( ! new_partition.name.empty() )
+       {
+               if ( ! name_partition( new_partition, operationdetail ) )
+                       return false;
+       }
+
+       if ( new_partition.type == TYPE_EXTENDED        ||
+            new_partition.filesystem == FS_UNFORMATTED    )
+               return true;
+       else if ( new_partition.filesystem == FS_CLEARED )
+               return erase_filesystem_signatures( new_partition, operationdetail );
+       else
+               return    erase_filesystem_signatures( new_partition, operationdetail )
+                      && set_partition_type( new_partition, operationdetail )
+                      && create_filesystem( new_partition, operationdetail );
+
+       return false;
 }
 
 bool GParted_Core::create_partition( Partition & new_partition, OperationDetail & operationdetail, Sector 
min_size )


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]