[gparted] Use supported_filesystem() predicate (#738471)



commit 88f67058e8aeb647914655833cec9f1fbafbb714
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sat Oct 11 20:58:18 2014 +0100

    Use supported_filesystem() predicate (#738471)
    
    Use GParted_Core::supported_filesystem() to remove the need to
    explicitly list the growing number of recognised, but otherwise
    unsupported, file system signatures in multiple places.
    
    Bug #738471 - ReFS file system is not recognised

 src/DialogFeatures.cc       |   13 +++----------
 src/Dialog_Partition_New.cc |    9 ++-------
 src/GParted_Core.cc         |   20 ++++----------------
 src/Win_GParted.cc          |   13 ++-----------
 4 files changed, 11 insertions(+), 44 deletions(-)
---
diff --git a/src/DialogFeatures.cc b/src/DialogFeatures.cc
index ee8af2a..adc379c 100644
--- a/src/DialogFeatures.cc
+++ b/src/DialogFeatures.cc
@@ -16,6 +16,7 @@
  */
  
 #include "../include/DialogFeatures.h" 
+#include "../include/GParted_Core.h"
 
 #include <gtkmm/stock.h>
 
@@ -142,16 +143,8 @@ void DialogFeatures::load_filesystems( const std::vector<FS> & FILESYSTEMS )
        //fill the features chart with valid file systems 
        for ( unsigned short t = 0; t < FILESYSTEMS .size() ; t++ )
        {
-               //Skip non-file systems or file systems only recognised but not otherwise supported
-               if (    FILESYSTEMS[ t ] .filesystem == FS_UNKNOWN
-                    || FILESYSTEMS[ t ] .filesystem == FS_CLEARED
-                    || FILESYSTEMS[ t ] .filesystem == FS_BITLOCKER
-                    || FILESYSTEMS[ t ] .filesystem == FS_LUKS
-                    || FILESYSTEMS[ t ] .filesystem == FS_LINUX_SWRAID
-                    || FILESYSTEMS[ t ] .filesystem == FS_LINUX_SWSUSPEND
-                  )
-                       continue ;
-               show_filesystem( FILESYSTEMS[ t ] ) ;
+               if ( GParted_Core::supported_filesystem( FILESYSTEMS[t].filesystem ) )
+                       show_filesystem( FILESYSTEMS[t] );
        }
 }
                
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 0222d4e..c525730 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -16,6 +16,7 @@
  */
 
 #include "../include/Dialog_Partition_New.h"
+#include "../include/GParted_Core.h"
 
 namespace GParted
 {
@@ -50,13 +51,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
        std::vector< FS >::iterator f ;
        for ( f = this->FILESYSTEMS .begin(); f != this->FILESYSTEMS .end(); f++ )
        {
-               if (   f ->filesystem == FS_UNKNOWN
-                   || f ->filesystem == FS_CLEARED
-                   || f ->filesystem == FS_BITLOCKER
-                   || f ->filesystem == FS_LUKS
-                   || f ->filesystem == FS_LINUX_SWRAID
-                   || f ->filesystem == FS_LINUX_SWSUSPEND
-                  )
+               if ( ! GParted_Core::supported_filesystem( f->filesystem ) )
                        //Compensate for subsequent 'f++' ...
                        f = this ->FILESYSTEMS .erase( f ) - 1 ;
        }
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index c893a88..7a44ea8 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1559,10 +1559,7 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
                     ) &&
                     partitions[ t ] .filesystem != FS_LINUX_SWAP      &&
                     partitions[ t ] .filesystem != FS_LVM2_PV         &&
-                    partitions[ t ] .filesystem != FS_BITLOCKER       &&
-                    partitions[ t ] .filesystem != FS_LUKS            &&
-                    partitions[ t ] .filesystem != FS_LINUX_SWRAID    &&
-                    partitions[ t ] .filesystem != FS_LINUX_SWSUSPEND
+                    supported_filesystem( partitions[ t ] .filesystem )
                   )
                {
                        if ( partitions[ t ] .busy )
@@ -1644,12 +1641,7 @@ bool GParted_Core::is_busy( FILESYSTEM fstype, const Glib::ustring & path )
        FileSystem * p_filesystem = NULL ;
        bool busy = false ;
 
-       if ( fstype != FS_UNKNOWN         &&
-            fstype != FS_BITLOCKER       &&
-            fstype != FS_LUKS            &&
-            fstype != FS_LINUX_SWRAID    &&
-            fstype != FS_LINUX_SWSUSPEND
-          )
+       if ( supported_filesystem( fstype ) )
        {
                switch ( get_fs( fstype ) .busy )
                {
@@ -1686,12 +1678,8 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions, PedDis
 {
        for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
        {
-               if ( partitions[ t ] .filesystem != FS_UNKNOWN         &&
-                    partitions[ t ] .filesystem != FS_BITLOCKER       &&
-                    partitions[ t ] .filesystem != FS_LUKS            &&
-                    partitions[ t ] .filesystem != FS_LINUX_SWRAID    &&
-                    partitions[ t ] .filesystem != FS_LINUX_SWSUSPEND
-                  )
+               if ( supported_filesystem( partitions[ t ] .filesystem ) ||
+                    partitions[t].filesystem == FS_EXTENDED                )
                {
                        if ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||
                             partitions[ t ] .type == GParted::TYPE_LOGICAL ) 
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index b971ac8..89ba006 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -416,17 +416,8 @@ Gtk::Menu * Win_GParted::create_format_menu()
 
        for ( unsigned int t = 0 ; t < fss .size() ; t++ )
        {
-               //Skip non-file systems or file systems only recognised but not otherwise supported
-               if (    fss[ t ] .filesystem == FS_UNKNOWN
-                    || fss[ t ] .filesystem == FS_CLEARED
-                    || fss[ t ] .filesystem == FS_BITLOCKER
-                    || fss[ t ] .filesystem == FS_LUKS
-                    || fss[ t ] .filesystem == FS_LINUX_SWRAID
-                    || fss[ t ] .filesystem == FS_LINUX_SWSUSPEND
-                  )
-                       continue ;
-
-               create_format_menu_add_item( fss[ t ] .filesystem, fss[ t ] .create ) ;
+               if ( GParted_Core::supported_filesystem( fss[t].filesystem ) )
+                       create_format_menu_add_item( fss[t].filesystem, fss[t].create );
        }
        //Add cleared at the end of the list
        create_format_menu_add_item( FS_CLEARED, true ) ;


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