Simplify GParted_Core::get_fs()

get_fs() used to work by (1) returning the supported capabilities of the
requested file system found in the FILESYSTEMS vector; (2) if not found
return the supported capabilities for file system FS_UNKNOWN; and (3)
if that wasn't found either, create a not supported capabilities set for
FS_UNKNOWN and return that.

This is more complicated that required.  Also the not supported
capabilities set, as created by struct FS() constructor, is the same as
that created in file_supported_filesystems() local variable fs_notsupp.

Simplify get_fs() just using a single not found code path returning a
not supported capabilities set.
This commit is contained in:
Mike Fleetwood 2015-11-12 19:14:48 +00:00 committed by Curtis Gedak
parent 320e166c03
commit 49664f3ca3
1 changed files with 5 additions and 12 deletions

View File

@ -932,26 +932,19 @@ const std::vector<FS> & GParted_Core::get_filesystems() const
return FILESYSTEMS ; return FILESYSTEMS ;
} }
// Return supported capabilities of the file system type or, if not found, not supported
// capabilities set.
const FS & GParted_Core::get_fs( GParted::FILESYSTEM filesystem ) const const FS & GParted_Core::get_fs( GParted::FILESYSTEM filesystem ) const
{ {
unsigned int unknown ;
unknown = FILESYSTEMS .size() ;
for ( unsigned int t = 0 ; t < FILESYSTEMS .size() ; t++ ) for ( unsigned int t = 0 ; t < FILESYSTEMS .size() ; t++ )
{ {
if ( FILESYSTEMS[ t ] .filesystem == filesystem ) if ( FILESYSTEMS[ t ] .filesystem == filesystem )
return FILESYSTEMS[ t ] ; return FILESYSTEMS[ t ] ;
else if ( FILESYSTEMS[ t ] .filesystem == FS_UNKNOWN )
unknown = t ;
} }
if ( unknown == FILESYSTEMS .size() ) { static FS fs_notsupp;
// This shouldn't happen, but just in case... fs_notsupp.filesystem = FS_UNKNOWN;
static FS fs; return fs_notsupp;
fs .filesystem = FS_UNKNOWN ;
return fs ;
} else
return FILESYSTEMS[ unknown ] ;
} }
//Return all libparted's partition table types in it's preferred ordering, //Return all libparted's partition table types in it's preferred ordering,