[file-roller/gnome-2-28] do not overwrite if not requested



commit 8d8de9c83a820d0bf936ed96ca01199cdb1f5c0f
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Nov 7 19:50:46 2009 +0100

    do not overwrite if not requested

 src/fr-archive.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/fr-archive.c b/src/fr-archive.c
index f5eb7a9..b176323 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -2122,7 +2122,8 @@ static void
 move_files_to_dir (FrArchive  *archive,
 		   GList      *file_list,
 		   const char *source_dir,
-		   const char *dest_dir)
+		   const char *dest_dir,
+		   gboolean    overwrite)
 {
 	GList *list;
 	GList *scan;
@@ -2142,7 +2143,11 @@ move_files_to_dir (FrArchive  *archive,
 		destname = g_build_filename (dest_dir, basename, NULL);
 		if (g_file_test (destname, G_FILE_TEST_IS_DIR)) {
 			fr_process_begin_command (archive->process, "cp");
-			fr_process_add_arg (archive->process, "-Rf");
+			fr_process_add_arg (archive->process, "-R");
+			if (overwrite)
+				fr_process_add_arg (archive->process, "-f");
+			else
+				fr_process_add_arg (archive->process, "-n");
 			if (filename[0] == '/')
 				fr_process_add_arg_concat (archive->process, source_dir, filename, NULL);
 			else
@@ -2166,7 +2171,10 @@ move_files_to_dir (FrArchive  *archive,
 	/* 'list' now contains the files that can be moved without problems */
 
 	fr_process_begin_command (archive->process, "mv");
-	fr_process_add_arg (archive->process, "-f");
+	if (overwrite)
+		fr_process_add_arg (archive->process, "-f");
+	else
+		fr_process_add_arg (archive->process, "-n");
 	for (scan = list; scan; scan = scan->next) {
 		char *filename = scan->data;
 
@@ -2186,7 +2194,8 @@ static void
 move_files_in_chunks (FrArchive  *archive,
 		      GList      *file_list,
 		      const char *temp_dir,
-		      const char *dest_dir)
+		      const char *dest_dir,
+		      gboolean    overwrite)
 {
 	GList *scan;
 	int    temp_dir_l;
@@ -2210,7 +2219,7 @@ move_files_in_chunks (FrArchive  *archive,
 		}
 
 		prev->next = NULL;
-		move_files_to_dir (archive, chunk_list, temp_dir, dest_dir);
+		move_files_to_dir (archive, chunk_list, temp_dir, dest_dir, overwrite);
 		prev->next = scan;
 	}
 }
@@ -2622,7 +2631,8 @@ fr_archive_extract_to_local (FrArchive  *archive,
 		move_files_in_chunks (archive,
 				      filtered,
 				      temp_dir,
-				      destination);
+				      destination,
+				      overwrite);
 
 		/* remove the temp dir. */
 



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