[gparted/refactor: 3/3] Pass Partition instead of just its path to FileSystem::copy()



commit a3e9012ef2590c066cea7c7d8ab6f2c7c552103d
Author: Phillip Susi <psusi ubuntu com>
Date:   Wed Jan 30 21:35:52 2013 -0500

    Pass Partition instead of just its path to FileSystem::copy()
    
    Other operations get the Partition object and can look up the path or other
    attributes they need.  The copy method should be no different.

 include/FileSystem.h |    4 ++--
 include/linux_swap.h |    4 ++--
 include/xfs.h        |    4 ++--
 src/GParted_Core.cc  |    4 ++--
 src/linux_swap.cc    |    4 ++--
 src/xfs.cc           |   14 +++++++-------
 6 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/include/FileSystem.h b/include/FileSystem.h
index 239e6c0..7578551 100644
--- a/include/FileSystem.h
+++ b/include/FileSystem.h
@@ -51,8 +51,8 @@ public:
 	                 , const Partition & partition_old
 	                 , OperationDetail & operationdetail
 			   ) { return false; };
-	virtual bool copy( const Glib::ustring & src_part_path,
-			   const Glib::ustring & dest_part_path,
+	virtual bool copy( const Partition & src_part,
+			   Partition & dest_part,
 			   OperationDetail & operationdetail ) { return false; };
 	virtual bool check_repair( const Partition & partition, OperationDetail & operationdetail ) { return false; };
 	virtual bool remove( const Partition & partition, OperationDetail & operationdetail ) { return true; };
diff --git a/include/linux_swap.h b/include/linux_swap.h
index 0420f27..c4be64c 100644
--- a/include/linux_swap.h
+++ b/include/linux_swap.h
@@ -41,8 +41,8 @@ public:
 	         , const Partition & partition_old
 	         , OperationDetail & operationdetail
 	         ) ;
-	bool copy( const Glib::ustring & src_part_path,
-		   const Glib::ustring & dest_part_path,
+	bool copy( const Partition & src_part,
+		   Partition & dest_part,
 		   OperationDetail & operationdetail ) ;
 };
 
diff --git a/include/xfs.h b/include/xfs.h
index 4b9d51e..faa6872 100644
--- a/include/xfs.h
+++ b/include/xfs.h
@@ -36,8 +36,8 @@ public:
 	bool write_uuid( const Partition & partition, OperationDetail & operationdetail ) ;
 	bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
 	bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
-	bool copy( const Glib::ustring & src_part_path,
-		   const Glib::ustring & dest_part_path,
+	bool copy( const Partition & src_part,
+		   Partition & dest_part,
 		   OperationDetail & operationdetail ) ;
 	bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
 };
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 3410050..1abce30 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -2609,8 +2609,8 @@ bool GParted_Core::copy( const Partition & partition_src,
 
 				case GParted::FS::EXTERNAL :
 					succes = ( p_filesystem = set_proper_filesystem( partition_dst .filesystem ) ) &&
-							 p_filesystem ->copy( partition_src .get_path(),
-								     	      partition_dst .get_path(),
+							 p_filesystem ->copy( partition_src,
+									      partition_dst,
 									      operationdetail .get_last_child() ) ;
 						break ;
 
diff --git a/src/linux_swap.cc b/src/linux_swap.cc
index 8374f01..f9c0886 100644
--- a/src/linux_swap.cc
+++ b/src/linux_swap.cc
@@ -149,8 +149,8 @@ bool linux_swap::move( const Partition & partition_new
 	return true ;
 }
 
-bool linux_swap::copy( const Glib::ustring & src_part_path,
-		       const Glib::ustring & dest_part_path,
+bool linux_swap::copy( const Partition & src_part,
+		       Partition & dest_part,
 		       OperationDetail & operationdetail )
 {
 	//Since linux-swap does not contain data, do not actually copy the partition
diff --git a/src/xfs.cc b/src/xfs.cc
index 60d0273..53505c8 100644
--- a/src/xfs.cc
+++ b/src/xfs.cc
@@ -194,13 +194,13 @@ bool xfs::resize( const Partition & partition_new, OperationDetail & operationde
 	return success ;
 }
 
-bool xfs::copy( const Glib::ustring & src_part_path,
-		const Glib::ustring & dest_part_path,
+bool xfs::copy( const Partition & src_part,
+		Partition & dest_part,
 		OperationDetail & operationdetail )
 {
 	bool success = true ;
 
-	success &= ! execute_command( "mkfs.xfs -f " + dest_part_path, operationdetail, true, true );
+	success &= ! execute_command( "mkfs.xfs -f " + dest_part.get_path(), operationdetail, true, true );
 	if ( ! success )
 		return false ;
 
@@ -215,12 +215,12 @@ bool xfs::copy( const Glib::ustring & src_part_path,
 		return false ;
 	}
 
-	success &= ! execute_command( "mount -v -t xfs -o noatime,ro " + src_part_path +
+	success &= ! execute_command( "mount -v -t xfs -o noatime,ro " + src_part.get_path() +
 				      " " + src_mount_point, operationdetail, true ) ;
 
 	if ( success )
 	{
-		success &= ! execute_command( "mount -v -t xfs " + dest_part_path +
+		success &= ! execute_command( "mount -v -t xfs " + dest_part.get_path() +
 					      " " + dest_mount_point, operationdetail, true ) ;
 
 		if ( success )
@@ -229,10 +229,10 @@ bool xfs::copy( const Glib::ustring & src_part_path,
 						      " | xfsrestore -J - " + dest_mount_point + "'",
 						      operationdetail, true, true );
 
-			success &= ! execute_command( "umount -v " + dest_part_path, operationdetail, true ) ;
+			success &= ! execute_command( "umount -v " + dest_part.get_path(), operationdetail, true ) ;
 		}
 
-		success &= ! execute_command( "umount -v " + src_part_path, operationdetail, true ) ;
+		success &= ! execute_command( "umount -v " + src_part.get_path(), operationdetail, true ) ;
 	}
 
 	rm_temp_dir( dest_mount_point, operationdetail ) ;



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