[gparted/psusi/refactor: 15/16] Combine duplicate code for ext[234]
- From: Phillip Susi <psusi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted/psusi/refactor: 15/16] Combine duplicate code for ext[234]
- Date: Tue, 29 Jan 2013 03:46:40 +0000 (UTC)
commit 77a6b002315cecf13d0ad11c9619cea4d82b453d
Author: Phillip Susi <psusi ubuntu com>
Date: Mon Jan 21 15:41:24 2013 -0500
Combine duplicate code for ext[234]
There were separate modules for ext3 and ext4 even though there
were virtually no differences with ext2. Remove the duplicate
modules and patch ext2 to serve as a common reference for all
three sub types.
include/ext2.h | 2 +
include/ext3.h | 53 -------------
include/ext4.h | 52 ------------
src/GParted_Core.cc | 8 +-
src/Makefile.am | 2 -
src/ext2.cc | 9 ++-
src/ext3.cc | 215 --------------------------------------------------
src/ext4.cc | 217 ---------------------------------------------------
8 files changed, 11 insertions(+), 547 deletions(-)
---
diff --git a/include/ext2.h b/include/ext2.h
index 6b76d62..8d4f9dc 100644
--- a/include/ext2.h
+++ b/include/ext2.h
@@ -27,7 +27,9 @@ namespace GParted
class ext2 : public FileSystem
{
+ const enum FILESYSTEM specific_type;
public:
+ ext2( enum FILESYSTEM type ) : specific_type( type ) {};
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;
void read_label( Partition & partition ) ;
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index ee0d458..3410050 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -33,8 +33,6 @@
#include "../include/btrfs.h"
#include "../include/exfat.h"
#include "../include/ext2.h"
-#include "../include/ext3.h"
-#include "../include/ext4.h"
#include "../include/fat16.h"
#include "../include/fat32.h"
#include "../include/linux_swap.h"
@@ -99,9 +97,9 @@ void GParted_Core::find_supported_filesystems()
FILESYSTEM_MAP[ FS_BTRFS ] = new btrfs() ;
FILESYSTEM_MAP[ FS_EXFAT ] = new exfat() ;
- FILESYSTEM_MAP[ FS_EXT2 ] = new ext2() ;
- FILESYSTEM_MAP[ FS_EXT3 ] = new ext3() ;
- FILESYSTEM_MAP[ FS_EXT4 ] = new ext4() ;
+ FILESYSTEM_MAP[ FS_EXT2 ] = new ext2( FS_EXT2 ) ;
+ FILESYSTEM_MAP[ FS_EXT3 ] = new ext2( FS_EXT3 ) ;
+ FILESYSTEM_MAP[ FS_EXT4 ] = new ext2( FS_EXT4 ) ;
FILESYSTEM_MAP[ FS_FAT16 ] = new fat16() ;
FILESYSTEM_MAP[ FS_FAT32 ] = new fat32() ;
FILESYSTEM_MAP[ FS_HFS ] = new hfs() ;
diff --git a/src/Makefile.am b/src/Makefile.am
index d5ec826..081f569 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,8 +50,6 @@ gpartedbin_SOURCES = \
btrfs.cc \
exfat.cc \
ext2.cc \
- ext3.cc \
- ext4.cc \
fat16.cc \
fat32.cc \
hfs.cc \
diff --git a/src/ext2.cc b/src/ext2.cc
index 56e38eb..c69a737 100644
--- a/src/ext2.cc
+++ b/src/ext2.cc
@@ -24,7 +24,7 @@ namespace GParted
FS ext2::get_filesystem_support()
{
FS fs ;
- fs .filesystem = FS_EXT2 ;
+ fs .filesystem = specific_type;
if ( ! Glib::find_program_in_path( "dumpe2fs" ) .empty() )
fs .read = FS::EXTERNAL ;
@@ -39,7 +39,7 @@ FS ext2::get_filesystem_support()
fs .write_label = FS::EXTERNAL ;
}
- if ( ! Glib::find_program_in_path( "mkfs.ext2" ) .empty() )
+ if ( ! Glib::find_program_in_path( "mke2fs" ) .empty() )
fs .create = FS::EXTERNAL ;
if ( ! Glib::find_program_in_path( "e2fsck" ) .empty() )
@@ -167,7 +167,10 @@ bool ext2::write_uuid( const Partition & partition, OperationDetail & operationd
bool ext2::create( const Partition & new_partition, OperationDetail & operationdetail )
{
- return ! execute_command( "mkfs.ext2 -L \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ;
+ return ! execute_command( "mke2fs -t " +
+ Utils::get_filesystem_string( specific_type ) +
+ " -L \"" + new_partition.get_label() + "\" " + new_partition.get_path(),
+ operationdetail) ;
}
bool ext2::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]