gparted r959 - in trunk: . include src



Author: gedakc
Date: Tue Nov 11 00:14:57 2008
New Revision: 959
URL: http://svn.gnome.org/viewvc/gparted?rev=959&view=rev

Log:
Added fat_compliant_label() method to limit volume labels to 11 characters.
Enforced fat compliant label for FAT16 and FAT32 file systems.

Modified:
   trunk/AUTHORS
   trunk/ChangeLog
   trunk/include/Utils.h
   trunk/src/Utils.cc
   trunk/src/fat16.cc
   trunk/src/fat32.cc

Modified: trunk/AUTHORS
==============================================================================
--- trunk/AUTHORS	(original)
+++ trunk/AUTHORS	Tue Nov 11 00:14:57 2008
@@ -12,6 +12,7 @@
 We need to keep track of copyright (see the Maintainer HOWTO on www.gnu.org).
 
 Curtis Gedak		<gedakc users sourceforge net>
+	* Wrote Utils::fat_compliant_label() method
 	* Wrote Utils::cleanup_cursor() function
 	* Rewrote read_label functionality for hfs
 	* Wrote create, read_label, and check_repair functionality for hfs+

Modified: trunk/include/Utils.h
==============================================================================
--- trunk/include/Utils.h	(original)
+++ trunk/include/Utils.h	Tue Nov 11 00:14:57 2008
@@ -136,6 +136,7 @@
 				    bool use_C_locale = false ) ;
 	static Glib::ustring regexp_label( const Glib::ustring & text,
 					const Glib::ustring & regular_sub_expression ) ;
+	static Glib::ustring fat_compliant_label( const Glib::ustring & label ) ;
 	static Glib::ustring create_mtoolsrc_file( char file_name[],
                     const char drive_letter, const Glib::ustring & device_path ) ;
 	static Glib::ustring delete_mtoolsrc_file( const char file_name[] ) ;

Modified: trunk/src/Utils.cc
==============================================================================
--- trunk/src/Utils.cc	(original)
+++ trunk/src/Utils.cc	Tue Nov 11 00:14:57 2008
@@ -279,6 +279,15 @@
 	return label ;
 }
 
+Glib::ustring Utils::fat_compliant_label( const Glib::ustring & label )
+{
+	//Limit volume label to 11 characters
+	Glib::ustring text = label ;
+	if( text .length() > 11 )
+		text .resize( 11 ) ;
+	return text ;
+}
+
 Glib::ustring Utils::create_mtoolsrc_file( char file_name[], const char drive_letter,
 		const Glib::ustring & device_path )
 {

Modified: trunk/src/fat16.cc
==============================================================================
--- trunk/src/fat16.cc	(original)
+++ trunk/src/fat16.cc	Tue Nov 11 00:14:57 2008
@@ -105,7 +105,7 @@
 
 	if ( ! Utils::execute_command( cmd, output, error, true ) )
 	{
-		partition .label = Utils::regexp_label( output, "Volume label is ([^(]*)" );
+		partition .label = Utils::trim( Utils::regexp_label( output, "Volume label is ([^(]*)" ) ) ;
 	}
 	else
 	{
@@ -132,7 +132,7 @@
 	if( partition .label .empty() )
 		cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ;
 	else
-		cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", fname, dletter, partition .label ) ;
+		cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", fname, dletter, Utils::fat_compliant_label( partition .label ) ) ;
 	
 	operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
 	
@@ -152,7 +152,7 @@
 
 bool fat16::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkdosfs -F16 -v -n \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
+	return ! execute_command( "mkdosfs -F16 -v -n \"" + Utils::fat_compliant_label( new_partition .label ) + "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool fat16::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )

Modified: trunk/src/fat32.cc
==============================================================================
--- trunk/src/fat32.cc	(original)
+++ trunk/src/fat32.cc	Tue Nov 11 00:14:57 2008
@@ -105,7 +105,7 @@
 
 	if ( ! Utils::execute_command( cmd, output, error, true ) )
 	{
-		partition .label = Utils::regexp_label( output, "Volume label is ([^(]*)" );
+		partition .label = Utils::trim( Utils::regexp_label( output, "Volume label is ([^(]*)" ) ) ;
 	}
 	else
 	{
@@ -132,7 +132,7 @@
 	if( partition .label .empty() )
 		cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ;
 	else
-		cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", fname, dletter, partition .label ) ;
+		cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", fname, dletter, Utils::fat_compliant_label( partition .label ) ) ;
 	operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
 	
 	int exit_status = Utils::execute_command( cmd, output, error ) ;
@@ -151,7 +151,7 @@
 
 bool fat32::create( const Partition & new_partition, OperationDetail & operationdetail )
 {
-	return ! execute_command( "mkdosfs -F32 -v -n \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
+	return ! execute_command( "mkdosfs -F32 -v -n \"" + Utils::fat_compliant_label( new_partition .label ) + "\" " + new_partition .get_path(), operationdetail ) ;
 }
 
 bool fat32::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )



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