[gparted/psusi/refactor: 16/19] Combine duplicate code for ext[234]



commit 4fcfc88290874412f144db7070326237567a0ca5
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/Makefile.am |    2 -
 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 ---------------------------------------------------
 9 files changed, 10 insertions(+), 550 deletions(-)
---
diff --git a/include/Makefile.am b/include/Makefile.am
index 7a8f1df..98a227c 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -40,8 +40,6 @@ EXTRA_DIST = \
        btrfs.h                         \
        exfat.h                         \
        ext2.h                          \
-       ext3.h                          \
-       ext4.h                          \
        fat16.h                         \
        fat32.h                         \
        hfs.h                           \
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 c169cb2..d2f5b63 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"
@@ -100,9 +98,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 16c0277..28feb63 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 2f113b5..1462162 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,8 +167,9 @@ 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(),
+       return ! execute_command( "mke2fs -t " +
+                                 Utils::get_filesystem_string( specific_type ) +
+                                 " -L \"" + new_partition.get_label() + "\" " + new_partition.get_path(),
                                  operationdetail,
                                  false,
                                  true );


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