gparted/src/OperationDelete.cc

143 lines
4.8 KiB
C++
Raw Normal View History

/* Copyright (C) 2004 Bart 'plors' Hakvoort
* Copyright (C) 2010 Curtis Gedak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "OperationDelete.h"
#include "Partition.h"
#include "PartitionVector.h"
namespace GParted
{
OperationDelete::OperationDelete( const Device & device, const Partition & partition_orig )
{
type = OPERATION_DELETE ;
this->device = device.get_copy_without_partitions();
this->partition_original = partition_orig.clone();
Use pointers to Partitions in Operation classes (#759726) Operation classes now internally use pointers to Partition objects and take on management of their lifetimes. As before, with the PartitionVector class, when storing pointers in a class the Big 3 of destructor, copy constructor and copy assignment operator also have to be considered. First, all the Partition objects are allocated in the derived Operation* class parameterised constructors and freed in the associated destructors. However the Operation classes are never copy constructed or copy assigned; they are only ever created and destroyed. Only pointers to the derived Operations are copied into the vector of pending operations. Therefore the copy construtor and copy assignment operator aren't needed. To enforce this provide inaccessible private declarations without any implementation so that the compiler will enforce this [1][2]. This example code fragment: 1 OperationCheck o1( device, partition ); 2 OperationCheck o2 = o1; 3 o2 = o1; Does these OperationCheck calls: 1 Implemented parameterised construtor, 2 Disallowed copy constructor, 3 Disallowed copy assignment Trying to compile the above code would fail with errors like these: ../include/OperationCheck.h: In member function 'void GParted::Win_GParted::activate_check()': ../include/OperationCheck.h:36:2: error: 'GParted::OperationCheck::OperationCheck(const GParted::OperationCheck&)' is private OperationCheck( const OperationCheck & src ); // Not implemented copy constructor ^ test.cc:2:21: error: within this context OperationCheck o2 = o1; ^ ../include/OperationCheck.h:37:19: error: 'GParted::OperationCheck& GParted::OperationCheck::operator=(const GParted::OperationCheck&)' is private OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator ^ test.cc:3:4: error: within this context o2 = o1; ^ [1] Disable copy constructor http://stackoverflow.com/questions/6077143/disable-copy-constructor [2] Disable compiler-generated copy-assignment operator [duplicate] http://stackoverflow.com/questions/7823845/disable-compiler-generated-copy-assignment-operator Bug 759726 - Implement Partition object polymorphism
2015-09-20 03:50:57 -06:00
}
OperationDelete::~OperationDelete()
{
delete partition_original;
partition_original = nullptr;
}
Partition & OperationDelete::get_partition_new()
{
g_assert( false ); // Bug: OperationDelete class doesn't use partition_new
// Not reached. Return value to keep compiler quiet.
Use pointers to Partitions in Operation classes (#759726) Operation classes now internally use pointers to Partition objects and take on management of their lifetimes. As before, with the PartitionVector class, when storing pointers in a class the Big 3 of destructor, copy constructor and copy assignment operator also have to be considered. First, all the Partition objects are allocated in the derived Operation* class parameterised constructors and freed in the associated destructors. However the Operation classes are never copy constructed or copy assigned; they are only ever created and destroyed. Only pointers to the derived Operations are copied into the vector of pending operations. Therefore the copy construtor and copy assignment operator aren't needed. To enforce this provide inaccessible private declarations without any implementation so that the compiler will enforce this [1][2]. This example code fragment: 1 OperationCheck o1( device, partition ); 2 OperationCheck o2 = o1; 3 o2 = o1; Does these OperationCheck calls: 1 Implemented parameterised construtor, 2 Disallowed copy constructor, 3 Disallowed copy assignment Trying to compile the above code would fail with errors like these: ../include/OperationCheck.h: In member function 'void GParted::Win_GParted::activate_check()': ../include/OperationCheck.h:36:2: error: 'GParted::OperationCheck::OperationCheck(const GParted::OperationCheck&)' is private OperationCheck( const OperationCheck & src ); // Not implemented copy constructor ^ test.cc:2:21: error: within this context OperationCheck o2 = o1; ^ ../include/OperationCheck.h:37:19: error: 'GParted::OperationCheck& GParted::OperationCheck::operator=(const GParted::OperationCheck&)' is private OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator ^ test.cc:3:4: error: within this context o2 = o1; ^ [1] Disable copy constructor http://stackoverflow.com/questions/6077143/disable-copy-constructor [2] Disable compiler-generated copy-assignment operator [duplicate] http://stackoverflow.com/questions/7823845/disable-compiler-generated-copy-assignment-operator Bug 759726 - Implement Partition object polymorphism
2015-09-20 03:50:57 -06:00
return *partition_new;
}
const Partition & OperationDelete::get_partition_new() const
{
g_assert( false ); // Bug: OperationDelete class doesn't use partition_new
// Not reached. Return value to keep compiler quiet.
Use pointers to Partitions in Operation classes (#759726) Operation classes now internally use pointers to Partition objects and take on management of their lifetimes. As before, with the PartitionVector class, when storing pointers in a class the Big 3 of destructor, copy constructor and copy assignment operator also have to be considered. First, all the Partition objects are allocated in the derived Operation* class parameterised constructors and freed in the associated destructors. However the Operation classes are never copy constructed or copy assigned; they are only ever created and destroyed. Only pointers to the derived Operations are copied into the vector of pending operations. Therefore the copy construtor and copy assignment operator aren't needed. To enforce this provide inaccessible private declarations without any implementation so that the compiler will enforce this [1][2]. This example code fragment: 1 OperationCheck o1( device, partition ); 2 OperationCheck o2 = o1; 3 o2 = o1; Does these OperationCheck calls: 1 Implemented parameterised construtor, 2 Disallowed copy constructor, 3 Disallowed copy assignment Trying to compile the above code would fail with errors like these: ../include/OperationCheck.h: In member function 'void GParted::Win_GParted::activate_check()': ../include/OperationCheck.h:36:2: error: 'GParted::OperationCheck::OperationCheck(const GParted::OperationCheck&)' is private OperationCheck( const OperationCheck & src ); // Not implemented copy constructor ^ test.cc:2:21: error: within this context OperationCheck o2 = o1; ^ ../include/OperationCheck.h:37:19: error: 'GParted::OperationCheck& GParted::OperationCheck::operator=(const GParted::OperationCheck&)' is private OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator ^ test.cc:3:4: error: within this context o2 = o1; ^ [1] Disable copy constructor http://stackoverflow.com/questions/6077143/disable-copy-constructor [2] Disable compiler-generated copy-assignment operator [duplicate] http://stackoverflow.com/questions/7823845/disable-compiler-generated-copy-assignment-operator Bug 759726 - Implement Partition object polymorphism
2015-09-20 03:50:57 -06:00
return *partition_new;
}
void OperationDelete::apply_to_visual( PartitionVector & partitions )
{
g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
Use pointers to Partitions in Operation classes (#759726) Operation classes now internally use pointers to Partition objects and take on management of their lifetimes. As before, with the PartitionVector class, when storing pointers in a class the Big 3 of destructor, copy constructor and copy assignment operator also have to be considered. First, all the Partition objects are allocated in the derived Operation* class parameterised constructors and freed in the associated destructors. However the Operation classes are never copy constructed or copy assigned; they are only ever created and destroyed. Only pointers to the derived Operations are copied into the vector of pending operations. Therefore the copy construtor and copy assignment operator aren't needed. To enforce this provide inaccessible private declarations without any implementation so that the compiler will enforce this [1][2]. This example code fragment: 1 OperationCheck o1( device, partition ); 2 OperationCheck o2 = o1; 3 o2 = o1; Does these OperationCheck calls: 1 Implemented parameterised construtor, 2 Disallowed copy constructor, 3 Disallowed copy assignment Trying to compile the above code would fail with errors like these: ../include/OperationCheck.h: In member function 'void GParted::Win_GParted::activate_check()': ../include/OperationCheck.h:36:2: error: 'GParted::OperationCheck::OperationCheck(const GParted::OperationCheck&)' is private OperationCheck( const OperationCheck & src ); // Not implemented copy constructor ^ test.cc:2:21: error: within this context OperationCheck o2 = o1; ^ ../include/OperationCheck.h:37:19: error: 'GParted::OperationCheck& GParted::OperationCheck::operator=(const GParted::OperationCheck&)' is private OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator ^ test.cc:3:4: error: within this context o2 = o1; ^ [1] Disable copy constructor http://stackoverflow.com/questions/6077143/disable-copy-constructor [2] Disable compiler-generated copy-assignment operator [duplicate] http://stackoverflow.com/questions/7823845/disable-compiler-generated-copy-assignment-operator Bug 759726 - Implement Partition object polymorphism
2015-09-20 03:50:57 -06:00
int index_extended;
int index;
Use pointers to Partitions in Operation classes (#759726) Operation classes now internally use pointers to Partition objects and take on management of their lifetimes. As before, with the PartitionVector class, when storing pointers in a class the Big 3 of destructor, copy constructor and copy assignment operator also have to be considered. First, all the Partition objects are allocated in the derived Operation* class parameterised constructors and freed in the associated destructors. However the Operation classes are never copy constructed or copy assigned; they are only ever created and destroyed. Only pointers to the derived Operations are copied into the vector of pending operations. Therefore the copy construtor and copy assignment operator aren't needed. To enforce this provide inaccessible private declarations without any implementation so that the compiler will enforce this [1][2]. This example code fragment: 1 OperationCheck o1( device, partition ); 2 OperationCheck o2 = o1; 3 o2 = o1; Does these OperationCheck calls: 1 Implemented parameterised construtor, 2 Disallowed copy constructor, 3 Disallowed copy assignment Trying to compile the above code would fail with errors like these: ../include/OperationCheck.h: In member function 'void GParted::Win_GParted::activate_check()': ../include/OperationCheck.h:36:2: error: 'GParted::OperationCheck::OperationCheck(const GParted::OperationCheck&)' is private OperationCheck( const OperationCheck & src ); // Not implemented copy constructor ^ test.cc:2:21: error: within this context OperationCheck o2 = o1; ^ ../include/OperationCheck.h:37:19: error: 'GParted::OperationCheck& GParted::OperationCheck::operator=(const GParted::OperationCheck&)' is private OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator ^ test.cc:3:4: error: within this context o2 = o1; ^ [1] Disable copy constructor http://stackoverflow.com/questions/6077143/disable-copy-constructor [2] Disable compiler-generated copy-assignment operator [duplicate] http://stackoverflow.com/questions/7823845/disable-compiler-generated-copy-assignment-operator Bug 759726 - Implement Partition object polymorphism
2015-09-20 03:50:57 -06:00
if ( partition_original->inside_extended )
{
index_extended = find_extended_partition( partitions );
if ( index_extended >= 0 )
{
index = find_index_original( partitions[ index_extended ] .logicals ) ;
if ( index >= 0 )
{
remove_original_and_adjacent_unallocated( partitions[index_extended].logicals, index );
insert_unallocated( partitions[index_extended].logicals,
partitions[index_extended].sector_start,
partitions[index_extended].sector_end,
device.sector_size,
true );
// If deleted partition was logical we have to decrease
// the partition numbers of the logicals with higher
// numbers by one (only if its a real partition)
Use pointers to Partitions in Operation classes (#759726) Operation classes now internally use pointers to Partition objects and take on management of their lifetimes. As before, with the PartitionVector class, when storing pointers in a class the Big 3 of destructor, copy constructor and copy assignment operator also have to be considered. First, all the Partition objects are allocated in the derived Operation* class parameterised constructors and freed in the associated destructors. However the Operation classes are never copy constructed or copy assigned; they are only ever created and destroyed. Only pointers to the derived Operations are copied into the vector of pending operations. Therefore the copy construtor and copy assignment operator aren't needed. To enforce this provide inaccessible private declarations without any implementation so that the compiler will enforce this [1][2]. This example code fragment: 1 OperationCheck o1( device, partition ); 2 OperationCheck o2 = o1; 3 o2 = o1; Does these OperationCheck calls: 1 Implemented parameterised construtor, 2 Disallowed copy constructor, 3 Disallowed copy assignment Trying to compile the above code would fail with errors like these: ../include/OperationCheck.h: In member function 'void GParted::Win_GParted::activate_check()': ../include/OperationCheck.h:36:2: error: 'GParted::OperationCheck::OperationCheck(const GParted::OperationCheck&)' is private OperationCheck( const OperationCheck & src ); // Not implemented copy constructor ^ test.cc:2:21: error: within this context OperationCheck o2 = o1; ^ ../include/OperationCheck.h:37:19: error: 'GParted::OperationCheck& GParted::OperationCheck::operator=(const GParted::OperationCheck&)' is private OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator ^ test.cc:3:4: error: within this context o2 = o1; ^ [1] Disable copy constructor http://stackoverflow.com/questions/6077143/disable-copy-constructor [2] Disable compiler-generated copy-assignment operator [duplicate] http://stackoverflow.com/questions/7823845/disable-compiler-generated-copy-assignment-operator Bug 759726 - Implement Partition object polymorphism
2015-09-20 03:50:57 -06:00
if ( partition_original->status != STAT_NEW )
for ( unsigned int t = 0 ; t < partitions[index_extended].logicals .size() ; t++ )
if ( partitions[index_extended].logicals[t].partition_number >
Use pointers to Partitions in Operation classes (#759726) Operation classes now internally use pointers to Partition objects and take on management of their lifetimes. As before, with the PartitionVector class, when storing pointers in a class the Big 3 of destructor, copy constructor and copy assignment operator also have to be considered. First, all the Partition objects are allocated in the derived Operation* class parameterised constructors and freed in the associated destructors. However the Operation classes are never copy constructed or copy assigned; they are only ever created and destroyed. Only pointers to the derived Operations are copied into the vector of pending operations. Therefore the copy construtor and copy assignment operator aren't needed. To enforce this provide inaccessible private declarations without any implementation so that the compiler will enforce this [1][2]. This example code fragment: 1 OperationCheck o1( device, partition ); 2 OperationCheck o2 = o1; 3 o2 = o1; Does these OperationCheck calls: 1 Implemented parameterised construtor, 2 Disallowed copy constructor, 3 Disallowed copy assignment Trying to compile the above code would fail with errors like these: ../include/OperationCheck.h: In member function 'void GParted::Win_GParted::activate_check()': ../include/OperationCheck.h:36:2: error: 'GParted::OperationCheck::OperationCheck(const GParted::OperationCheck&)' is private OperationCheck( const OperationCheck & src ); // Not implemented copy constructor ^ test.cc:2:21: error: within this context OperationCheck o2 = o1; ^ ../include/OperationCheck.h:37:19: error: 'GParted::OperationCheck& GParted::OperationCheck::operator=(const GParted::OperationCheck&)' is private OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator ^ test.cc:3:4: error: within this context o2 = o1; ^ [1] Disable copy constructor http://stackoverflow.com/questions/6077143/disable-copy-constructor [2] Disable compiler-generated copy-assignment operator [duplicate] http://stackoverflow.com/questions/7823845/disable-compiler-generated-copy-assignment-operator Bug 759726 - Implement Partition object polymorphism
2015-09-20 03:50:57 -06:00
partition_original->partition_number )
partitions[index_extended].logicals[t].Update_Number(
partitions[index_extended].logicals[t].partition_number -1 );
}
}
}
else
{
index = find_index_original( partitions ) ;
if ( index >= 0 )
{
remove_original_and_adjacent_unallocated( partitions, index ) ;
insert_unallocated( partitions, 0, device .length -1, device .sector_size, false ) ;
}
}
}
void OperationDelete::create_description()
{
g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
Use pointers to Partitions in Operation classes (#759726) Operation classes now internally use pointers to Partition objects and take on management of their lifetimes. As before, with the PartitionVector class, when storing pointers in a class the Big 3 of destructor, copy constructor and copy assignment operator also have to be considered. First, all the Partition objects are allocated in the derived Operation* class parameterised constructors and freed in the associated destructors. However the Operation classes are never copy constructed or copy assigned; they are only ever created and destroyed. Only pointers to the derived Operations are copied into the vector of pending operations. Therefore the copy construtor and copy assignment operator aren't needed. To enforce this provide inaccessible private declarations without any implementation so that the compiler will enforce this [1][2]. This example code fragment: 1 OperationCheck o1( device, partition ); 2 OperationCheck o2 = o1; 3 o2 = o1; Does these OperationCheck calls: 1 Implemented parameterised construtor, 2 Disallowed copy constructor, 3 Disallowed copy assignment Trying to compile the above code would fail with errors like these: ../include/OperationCheck.h: In member function 'void GParted::Win_GParted::activate_check()': ../include/OperationCheck.h:36:2: error: 'GParted::OperationCheck::OperationCheck(const GParted::OperationCheck&)' is private OperationCheck( const OperationCheck & src ); // Not implemented copy constructor ^ test.cc:2:21: error: within this context OperationCheck o2 = o1; ^ ../include/OperationCheck.h:37:19: error: 'GParted::OperationCheck& GParted::OperationCheck::operator=(const GParted::OperationCheck&)' is private OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator ^ test.cc:3:4: error: within this context o2 = o1; ^ [1] Disable copy constructor http://stackoverflow.com/questions/6077143/disable-copy-constructor [2] Disable compiler-generated copy-assignment operator [duplicate] http://stackoverflow.com/questions/7823845/disable-compiler-generated-copy-assignment-operator Bug 759726 - Implement Partition object polymorphism
2015-09-20 03:50:57 -06:00
if ( partition_original->type == TYPE_LOGICAL )
description = _("Logical Partition") ;
else
Use pointers to Partitions in Operation classes (#759726) Operation classes now internally use pointers to Partition objects and take on management of their lifetimes. As before, with the PartitionVector class, when storing pointers in a class the Big 3 of destructor, copy constructor and copy assignment operator also have to be considered. First, all the Partition objects are allocated in the derived Operation* class parameterised constructors and freed in the associated destructors. However the Operation classes are never copy constructed or copy assigned; they are only ever created and destroyed. Only pointers to the derived Operations are copied into the vector of pending operations. Therefore the copy construtor and copy assignment operator aren't needed. To enforce this provide inaccessible private declarations without any implementation so that the compiler will enforce this [1][2]. This example code fragment: 1 OperationCheck o1( device, partition ); 2 OperationCheck o2 = o1; 3 o2 = o1; Does these OperationCheck calls: 1 Implemented parameterised construtor, 2 Disallowed copy constructor, 3 Disallowed copy assignment Trying to compile the above code would fail with errors like these: ../include/OperationCheck.h: In member function 'void GParted::Win_GParted::activate_check()': ../include/OperationCheck.h:36:2: error: 'GParted::OperationCheck::OperationCheck(const GParted::OperationCheck&)' is private OperationCheck( const OperationCheck & src ); // Not implemented copy constructor ^ test.cc:2:21: error: within this context OperationCheck o2 = o1; ^ ../include/OperationCheck.h:37:19: error: 'GParted::OperationCheck& GParted::OperationCheck::operator=(const GParted::OperationCheck&)' is private OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator ^ test.cc:3:4: error: within this context o2 = o1; ^ [1] Disable copy constructor http://stackoverflow.com/questions/6077143/disable-copy-constructor [2] Disable compiler-generated copy-assignment operator [duplicate] http://stackoverflow.com/questions/7823845/disable-compiler-generated-copy-assignment-operator Bug 759726 - Implement Partition object polymorphism
2015-09-20 03:50:57 -06:00
description = partition_original->get_path();
/*TO TRANSLATORS: looks like Delete /dev/hda2 (ntfs, 345 MiB) from /dev/hda */
description = Glib::ustring::compose( _("Delete %1 (%2, %3) from %4"),
Use pointers to Partitions in Operation classes (#759726) Operation classes now internally use pointers to Partition objects and take on management of their lifetimes. As before, with the PartitionVector class, when storing pointers in a class the Big 3 of destructor, copy constructor and copy assignment operator also have to be considered. First, all the Partition objects are allocated in the derived Operation* class parameterised constructors and freed in the associated destructors. However the Operation classes are never copy constructed or copy assigned; they are only ever created and destroyed. Only pointers to the derived Operations are copied into the vector of pending operations. Therefore the copy construtor and copy assignment operator aren't needed. To enforce this provide inaccessible private declarations without any implementation so that the compiler will enforce this [1][2]. This example code fragment: 1 OperationCheck o1( device, partition ); 2 OperationCheck o2 = o1; 3 o2 = o1; Does these OperationCheck calls: 1 Implemented parameterised construtor, 2 Disallowed copy constructor, 3 Disallowed copy assignment Trying to compile the above code would fail with errors like these: ../include/OperationCheck.h: In member function 'void GParted::Win_GParted::activate_check()': ../include/OperationCheck.h:36:2: error: 'GParted::OperationCheck::OperationCheck(const GParted::OperationCheck&)' is private OperationCheck( const OperationCheck & src ); // Not implemented copy constructor ^ test.cc:2:21: error: within this context OperationCheck o2 = o1; ^ ../include/OperationCheck.h:37:19: error: 'GParted::OperationCheck& GParted::OperationCheck::operator=(const GParted::OperationCheck&)' is private OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator ^ test.cc:3:4: error: within this context o2 = o1; ^ [1] Disable copy constructor http://stackoverflow.com/questions/6077143/disable-copy-constructor [2] Disable compiler-generated copy-assignment operator [duplicate] http://stackoverflow.com/questions/7823845/disable-compiler-generated-copy-assignment-operator Bug 759726 - Implement Partition object polymorphism
2015-09-20 03:50:57 -06:00
description,
partition_original->get_filesystem_string(),
Use pointers to Partitions in Operation classes (#759726) Operation classes now internally use pointers to Partition objects and take on management of their lifetimes. As before, with the PartitionVector class, when storing pointers in a class the Big 3 of destructor, copy constructor and copy assignment operator also have to be considered. First, all the Partition objects are allocated in the derived Operation* class parameterised constructors and freed in the associated destructors. However the Operation classes are never copy constructed or copy assigned; they are only ever created and destroyed. Only pointers to the derived Operations are copied into the vector of pending operations. Therefore the copy construtor and copy assignment operator aren't needed. To enforce this provide inaccessible private declarations without any implementation so that the compiler will enforce this [1][2]. This example code fragment: 1 OperationCheck o1( device, partition ); 2 OperationCheck o2 = o1; 3 o2 = o1; Does these OperationCheck calls: 1 Implemented parameterised construtor, 2 Disallowed copy constructor, 3 Disallowed copy assignment Trying to compile the above code would fail with errors like these: ../include/OperationCheck.h: In member function 'void GParted::Win_GParted::activate_check()': ../include/OperationCheck.h:36:2: error: 'GParted::OperationCheck::OperationCheck(const GParted::OperationCheck&)' is private OperationCheck( const OperationCheck & src ); // Not implemented copy constructor ^ test.cc:2:21: error: within this context OperationCheck o2 = o1; ^ ../include/OperationCheck.h:37:19: error: 'GParted::OperationCheck& GParted::OperationCheck::operator=(const GParted::OperationCheck&)' is private OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator ^ test.cc:3:4: error: within this context o2 = o1; ^ [1] Disable copy constructor http://stackoverflow.com/questions/6077143/disable-copy-constructor [2] Disable compiler-generated copy-assignment operator [duplicate] http://stackoverflow.com/questions/7823845/disable-compiler-generated-copy-assignment-operator Bug 759726 - Implement Partition object polymorphism
2015-09-20 03:50:57 -06:00
Utils::format_size( partition_original->get_sector_length(),
partition_original->sector_size ),
partition_original->device_path );
}
bool OperationDelete::merge_operations( const Operation & candidate )
{
return false; // Can't merge with an already deleted partition
}
void OperationDelete::remove_original_and_adjacent_unallocated( PartitionVector & partitions, int index_orig )
{
//remove unallocated space following the original partition
if ( index_orig +1 < static_cast<int>( partitions .size() ) &&
partitions[index_orig+1].type == TYPE_UNALLOCATED )
partitions .erase( partitions .begin() + index_orig +1 );
//remove unallocated space preceding the original partition and the original partition
if (index_orig-1 >= 0 && partitions[index_orig-1].type == TYPE_UNALLOCATED)
partitions .erase( partitions .begin() + --index_orig ) ;
//and finally remove the original partition
partitions .erase( partitions .begin() + index_orig ) ;
}
} //GParted