From b12fbfb1b26bac94a7b8ab4539e6c925ddcc6479 Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Fri, 25 Jul 2008 22:19:50 +0000 Subject: [PATCH] Enhanced support for hfsplus file system svn path=/trunk/; revision=871 --- AUTHORS | 1 + ChangeLog | 6 ++++++ src/hfsplus.cc | 35 +++++++++++++++++++++++++++++++---- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 5cd00253..019302ef 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,6 +12,7 @@ not an invitation to misrepresent who contributed to GNU GParted. We need to keep track of copyright (see the Maintainer HOWTO on www.gnu.org). Curtis Gedak + * Wrote create, get_label, and check_repair functionality for hfs+ * Wrote get_label functionality for fat16 and fat32 filesystems * Wrote Utils::regexp_label() function * Wrote set partition label functionality diff --git a/ChangeLog b/ChangeLog index c5e14c3e..41340753 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-07-25 Curtis Gedak + + * src/hfsplus.cc: Enhanced support for hfsplus file system + - Added create, get_label, and check_repair functionality + - Additional feature support is provided by the hfsprogs package + 2008-07-23 Curtis Gedak * gparted.desktop.in.in, diff --git a/src/hfsplus.cc b/src/hfsplus.cc index e31e8c4e..f1254e9f 100644 --- a/src/hfsplus.cc +++ b/src/hfsplus.cc @@ -30,6 +30,15 @@ FS hfsplus::get_filesystem_support() fs .read = GParted::FS::LIBPARTED ; fs .shrink = GParted::FS::LIBPARTED ; + if ( ! Glib::find_program_in_path( "mkfs.hfsplus" ) .empty() ) + fs .create = GParted::FS::EXTERNAL ; + + if ( ! Glib::find_program_in_path( "fsck.hfsplus" ) .empty() ) + fs .check = FS::EXTERNAL ; + + if ( ! Glib::find_program_in_path( "vol_id" ) .empty() ) + fs .get_label = FS::EXTERNAL ; + fs .copy = GParted::FS::GPARTED ; fs .move = GParted::FS::GPARTED ; @@ -42,6 +51,21 @@ void hfsplus::set_used_sectors( Partition & partition ) void hfsplus::get_label( Partition & partition ) { + if ( ! Utils::execute_command( "vol_id " + partition .get_path(), output, error, true ) ) + { + Glib::ustring label = Utils::regexp_label( output, "ID_FS_LABEL=([^\n]*)" ) ; + //FIXME: find a better way to see if label is empty.. imagine someone uses 'untitled' as label.... ;) + if( label != "untitled" ) + partition .label = label ; + } + else + { + if ( ! output .empty() ) + partition .messages .push_back( output ) ; + + if ( ! error .empty() ) + partition .messages .push_back( error ) ; + } } bool hfsplus::set_label( const Partition & partition, OperationDetail & operationdetail ) @@ -51,7 +75,12 @@ bool hfsplus::set_label( const Partition & partition, OperationDetail & operatio bool hfsplus::create( const Partition & new_partition, OperationDetail & operationdetail ) { - return true ; + Glib::ustring cmd = ""; + if( new_partition .label .empty() ) + cmd = "mkfs.hfsplus " + new_partition .get_path() ; + else + cmd = "mkfs.hfsplus -v \"" + new_partition .label + "\" " + new_partition .get_path() ; + return ! execute_command( cmd , operationdetail ) ; } bool hfsplus::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition ) @@ -68,9 +97,7 @@ bool hfsplus::copy( const Glib::ustring & src_part_path, bool hfsplus::check_repair( const Partition & partition, OperationDetail & operationdetail ) { - return true ; + return ! execute_command( "fsck.hfsplus -f -y " + partition .get_path(), operationdetail ) ; } } //GParted - -