[PATCH] Mention the offending filename in the nautilus-cd-burner invalid encoding error (now with attachment)



Here is a patch, that makes the invalid encoding error dialog mention
which file is offending - otherwise it can be quite difficult to track
down :-)

Please provide feedback if something is wrong. My supply of C-mojo is
not that high yet...

-- 
Mads Chr. Olesen <nautilus-maillist shiyee dk>
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/ChangeLog,v
retrieving revision 1.520
diff -u -r1.520 ChangeLog
--- ChangeLog	14 Nov 2005 17:02:35 -0000	1.520
+++ ChangeLog	18 Nov 2005 20:46:05 -0000
@@ -1,3 +1,8 @@
+2005-11-18  Mads Chr. Olesen  <nautilus-cd-burner shiyee dk>
+
+	* make-iso.c: Mention invalid filename in the invalid encoding error
+	dialog.
+
 2005-11-14  William Jon McCann  <mccann jhu edu>
 
 	* configure.in: Post release version bump.
Index: make-iso.c
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/make-iso.c,v
retrieving revision 1.63
diff -u -r1.63 make-iso.c
--- make-iso.c	7 Nov 2005 17:57:10 -0000	1.63
+++ make-iso.c	18 Nov 2005 20:46:06 -0000
@@ -623,6 +623,45 @@
 	mkisofs_output->result = NAUTILUS_BURN_RECORDER_RESULT_ERROR;
 }
 
+/* Originally eel_make_valid_utf8 */
+static char *
+ncb_make_valid_utf8 (const char *name)
+{
+	GString    *string;
+	const char *remainder, *invalid;
+	int         remaining_bytes, valid_bytes;
+
+	string = NULL;
+	remainder = name;
+	remaining_bytes = strlen (name);
+
+	while (remaining_bytes != 0) {
+		if (g_utf8_validate (remainder, remaining_bytes, &invalid)) {
+			break;
+		}
+		valid_bytes = invalid - remainder;
+
+		if (string == NULL) {
+			string = g_string_sized_new (remaining_bytes);
+		}
+		g_string_append_len (string, remainder, valid_bytes);
+		g_string_append_c (string, '?');
+
+		remaining_bytes -= valid_bytes + 1;
+		remainder = invalid + 1;
+	}
+
+	if (string == NULL) {
+		return g_strdup (name);
+	}
+
+	g_string_append (string, remainder);
+	g_string_append (string, _(" (invalid Unicode)"));
+	g_assert (g_utf8_validate (string->str, -1, NULL));
+
+	return g_string_free (string, FALSE);
+}
+
 static gboolean  
 mkisofs_stderr_read (GIOChannel   *source,
 		     GIOCondition  condition,
@@ -672,7 +711,23 @@
 			}
 
 			if (strstr (line, "Incorrectly encoded string")) {
-				mkisofs_output_error (mkisofs_output, _("Some files have invalid filenames."));
+				GString *filename = g_string_sized_new(32);
+				gchar *utf8_filename;
+				gchar *msg;
+
+				g_string_assign(filename, line);
+				//Erase up to the first (
+				g_string_erase(filename, 0, strchr(filename->str, '(') - filename->str + 1);
+				//Truncate down to the last )
+				g_string_truncate(filename, strrchr(filename->str, ')') - filename->str - 1);
+				printf("%s", filename->str);
+				
+				utf8_filename = ncb_make_valid_utf8(filename->str);
+				msg = g_strconcat(_("Some files have invalid filenames: \n\""), utf8_filename, "\"", NULL);
+				
+				mkisofs_output_error (mkisofs_output, msg);
+				g_free(msg);
+				g_free(utf8_filename);
 			}
 
 			if (strstr (line, "Unknown charset")) {
@@ -1616,45 +1671,6 @@
 	}
 
 	return mkisofs_output.result;
-}
-
-/* Originally eel_make_valid_utf8 */
-static char *
-ncb_make_valid_utf8 (const char *name)
-{
-	GString    *string;
-	const char *remainder, *invalid;
-	int         remaining_bytes, valid_bytes;
-
-	string = NULL;
-	remainder = name;
-	remaining_bytes = strlen (name);
-
-	while (remaining_bytes != 0) {
-		if (g_utf8_validate (remainder, remaining_bytes, &invalid)) {
-			break;
-		}
-		valid_bytes = invalid - remainder;
-
-		if (string == NULL) {
-			string = g_string_sized_new (remaining_bytes);
-		}
-		g_string_append_len (string, remainder, valid_bytes);
-		g_string_append_c (string, '?');
-
-		remaining_bytes -= valid_bytes + 1;
-		remainder = invalid + 1;
-	}
-
-	if (string == NULL) {
-		return g_strdup (name);
-	}
-
-	g_string_append (string, remainder);
-	g_string_append (string, _(" (invalid Unicode)"));
-	g_assert (g_utf8_validate (string->str, -1, NULL));
-
-	return g_string_free (string, FALSE);
 }
 
 /**


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