cleanups in the core and the fs'es (create)

* cleanups in the core and the fs'es (create)
This commit is contained in:
Bart Hakvoort 2006-06-17 08:56:24 +00:00
parent 50912f2049
commit 682283ce89
14 changed files with 51 additions and 75 deletions

View File

@ -1,3 +1,7 @@
2006-06-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
* cleanups in the core and the fs'es (create)
2006-06-04 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/GParted_Core.cc: removed 'EXPERIMENTAL' from move-message to

View File

@ -88,9 +88,10 @@ private:
std::vector<Glib::ustring> get_alternate_paths( const Glib::ustring & path ) ;
void LP_Set_Used_Sectors( Partition & partition );
void set_flags( Partition & partition ) ;
bool create_empty_partition( Partition & new_partition,
bool create_partition( Partition & new_partition,
std::vector<OperationDetails> & operation_details,
Sector min_size = 0 ) ;
bool create_filesystem( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
bool resize_container_partition( const Partition & partition_old,
Partition & partition_new,
bool fixed_start,

View File

@ -672,19 +672,15 @@ bool GParted_Core::create( const Device & device,
if ( new_partition .type == GParted::TYPE_EXTENDED )
{
return create_empty_partition( new_partition, operation_details ) ;
return create_partition( new_partition, operation_details ) ;
}
else if ( create_empty_partition( new_partition, operation_details, get_fs( new_partition .filesystem ) .MIN ) )
else if ( create_partition( new_partition, operation_details, get_fs( new_partition .filesystem ) .MIN ) )
{
set_proper_filesystem( new_partition .filesystem ) ;
//most likely this means the user created an unformatted partition,
//however in theory, it could also screw some errorhandling.
if ( ! p_filesystem )
if ( new_partition .filesystem == GParted::FS_UNFORMATTED )
return true ;
else
return set_partition_type( new_partition, operation_details ) &&
p_filesystem ->Create( new_partition, operation_details ) ;
create_filesystem( new_partition, operation_details ) ;
}
return false ;
@ -852,7 +848,7 @@ bool GParted_Core::move_partition( const Partition & partition_old,
ped_device_close( lp_device );
//FIXME: errorhandling moet stukken beter voordat we committen!
//FIXME: errorhandling needs to be improved!
succes = resize_container_partition( partition_old,
partition_new,
false,
@ -941,7 +937,7 @@ bool GParted_Core::copy( const Partition & partition_src,
{
bool succes = true ;
if ( partition_dest .status == GParted::STAT_NEW )
succes = create_empty_partition( partition_dest, operation_details, min_size ) ;
succes = create_partition( partition_dest, operation_details, min_size ) ;
if ( succes && set_partition_type( partition_dest, operation_details ) )
{
@ -1135,7 +1131,7 @@ void GParted_Core::LP_Set_Used_Sectors( Partition & partition )
partition .error = ped_error ;
}
bool GParted_Core::create_empty_partition( Partition & new_partition,
bool GParted_Core::create_partition( Partition & new_partition,
std::vector<OperationDetails> & operation_details,
Sector min_size )
{
@ -1251,6 +1247,26 @@ bool GParted_Core::create_empty_partition( Partition & new_partition,
}
}
bool GParted_Core::create_filesystem( const Partition & partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( partition .filesystem ) ) ) ) ;
set_proper_filesystem( partition .filesystem ) ;
if ( p_filesystem && p_filesystem ->Create( partition, operation_details .back() .sub_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;
}
else
{
operation_details .back() .status = OperationDetails::ERROR ;
return false ;
}
}
bool GParted_Core::resize_container_partition( const Partition & partition_old,
Partition & partition_new,
bool fixed_start,

View File

@ -75,11 +75,7 @@ void ext2::Set_Used_Sectors( Partition & partition )
bool ext2::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( GParted::FS_EXT2 ) ) ) ) ;
if ( ! execute_command( "mkfs.ext2 " + new_partition .get_path(), operation_details .back() .sub_details ) )
if ( ! execute_command( "mkfs.ext2 " + new_partition .get_path(), operation_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;

View File

@ -70,11 +70,7 @@ void ext3::Set_Used_Sectors( Partition & partition )
bool ext3::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( GParted::FS_EXT3 ) ) ) ) ;
if ( ! execute_command( "mkfs.ext3 " + new_partition .get_path(), operation_details .back() .sub_details ) )
if ( ! execute_command( "mkfs.ext3 " + new_partition .get_path(), operation_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;

View File

@ -75,11 +75,7 @@ void fat16::Set_Used_Sectors( Partition & partition )
bool fat16::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( GParted::FS_FAT16 ) ) ) ) ;
if ( ! execute_command( "mkdosfs -F16 -v " + new_partition .get_path(), operation_details .back() .sub_details ) )
if ( ! execute_command( "mkdosfs -F16 -v " + new_partition .get_path(), operation_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;

View File

@ -76,11 +76,7 @@ void fat32::Set_Used_Sectors( Partition & partition )
bool fat32::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( GParted::FS_FAT32 ) ) ) ) ;
if ( ! execute_command( "mkdosfs -F32 -v " + new_partition .get_path(), operation_details .back() .sub_details ) )
if ( ! execute_command( "mkdosfs -F32 -v " + new_partition .get_path(), operation_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;

View File

@ -46,11 +46,7 @@ void hfs::Set_Used_Sectors( Partition & partition )
bool hfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( GParted::FS_HFS ) ) ) ) ;
if ( ! execute_command( "hformat " + new_partition .get_path(), operation_details .back() .sub_details ) )
if ( ! execute_command( "hformat " + new_partition .get_path(), operation_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;

View File

@ -91,11 +91,7 @@ void jfs::Set_Used_Sectors( Partition & partition )
bool jfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( GParted::FS_JFS ) ) ) ) ;
if ( ! execute_command( "mkfs.jfs -q " + new_partition .get_path(), operation_details .back() .sub_details ) )
if ( ! execute_command( "mkfs.jfs -q " + new_partition .get_path(), operation_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;

View File

@ -45,12 +45,7 @@ void linux_swap::Set_Used_Sectors( Partition & partition )
bool linux_swap::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back(
OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( GParted::FS_LINUX_SWAP ) ) ) ) ;
if ( ! execute_command( "mkswap " + new_partition .get_path(), operation_details .back() .sub_details ) )
if ( ! execute_command( "mkswap " + new_partition .get_path(), operation_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;

View File

@ -69,11 +69,7 @@ void ntfs::Set_Used_Sectors( Partition & partition )
bool ntfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( GParted::FS_NTFS ) ) ) ) ;
if ( ! execute_command( "mkntfs -Q -vv " + new_partition .get_path(), operation_details .back() .sub_details ) )
if ( ! execute_command( "mkntfs -Q -vv " + new_partition .get_path(), operation_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;

View File

@ -68,11 +68,7 @@ void reiser4::Set_Used_Sectors( Partition & partition )
bool reiser4::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( GParted::FS_REISER4 ) ) ) ) ;
if ( ! execute_command( "mkfs.reiser4 --yes " + new_partition .get_path(), operation_details .back() .sub_details ) )
if ( ! execute_command( "mkfs.reiser4 --yes " + new_partition .get_path(), operation_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;

View File

@ -73,11 +73,7 @@ void reiserfs::Set_Used_Sectors( Partition & partition )
bool reiserfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( GParted::FS_REISERFS ) ) ) ) ;
if ( ! execute_command( "mkreiserfs -f " + new_partition .get_path(), operation_details .back() .sub_details ) )
if ( ! execute_command( "mkreiserfs -f " + new_partition .get_path(), operation_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;

View File

@ -93,11 +93,7 @@ void xfs::Set_Used_Sectors( Partition & partition )
bool xfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
{
operation_details .push_back( OperationDetails( String::ucompose(
_("create new %1 filesystem"),
Utils::get_filesystem_string( GParted::FS_XFS ) ) ) ) ;
if ( ! execute_command( "mkfs.xfs -f " + new_partition .get_path(), operation_details .back() .sub_details ) )
if ( ! execute_command( "mkfs.xfs -f " + new_partition .get_path(), operation_details ) )
{
operation_details .back() .status = OperationDetails::SUCCES ;
return true ;