gvfs r1807 - in trunk: . programs



Author: rburton
Date: Wed Jun 11 16:19:39 2008
New Revision: 1807
URL: http://svn.gnome.org/viewvc/gvfs?rev=1807&view=rev

Log:
2008-06-11  Ross Burton  <ross burtonini com>

	* programs/gvfs-mkdir.c:
	Add -p to create parents (using
	g_file_make_directory_with_parents, just landed in glib).  Patch
	from A Walton (#511367)


Modified:
   trunk/ChangeLog
   trunk/programs/gvfs-mkdir.c

Modified: trunk/programs/gvfs-mkdir.c
==============================================================================
--- trunk/programs/gvfs-mkdir.c	(original)
+++ trunk/programs/gvfs-mkdir.c	Wed Jun 11 16:19:39 2008
@@ -23,11 +23,14 @@
 #include <config.h>
 
 #include <glib.h>
+#include <glib/gi18n.h>
 #include <locale.h>
 #include <gio/gio.h>
 
+static gboolean parent = FALSE;
 static GOptionEntry entries[] = 
 {
+	{ "parent", 'p', 0, G_OPTION_ARG_NONE, &parent, "create parent directories", NULL },
 	{ NULL }
 };
 
@@ -48,21 +51,44 @@
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
   g_option_context_parse (context, &argc, &argv, &error);
   g_option_context_free (context);
+
+  if (error != NULL)
+    {
+      g_printerr ("Error parsing commandline options: %s\n", error->message);
+      g_printerr ("\n");
+      g_printerr (_("Try \"%s --help\" for more information."),
+                  g_get_prgname ());
+      g_printerr ("\n");
+      g_error_free(error);
+      return 1;
+    }
   
   if (argc > 1)
     {
       int i;
       
-      for (i = 1; i < argc; i++) {
-	file = g_file_new_for_commandline_arg (argv[i]);
-	error = NULL;
-	if (!g_file_make_directory (file, NULL, &error))
-	  {
-	    g_print ("Error creating directory: %s\n", error->message);
-	    g_error_free (error);
-	  }
-	g_object_unref (file);
-      }
+      for (i = 1; i < argc; i++) 
+        {
+	  file = g_file_new_for_commandline_arg (argv[i]);
+          error = NULL;
+          if (parent)
+            {
+               if (!g_file_make_directory_with_parents (file, NULL, &error))
+	        {
+	          g_print ("Error creating directory: %s\n", error->message);
+	          g_error_free (error);
+	        } 
+            }
+          else
+            {
+	      if (!g_file_make_directory (file, NULL, &error))
+	        {
+	          g_print ("Error creating directory: %s\n", error->message);
+	          g_error_free (error);
+	        }
+              g_object_unref (file);
+            }
+        }
     }
 
   return 0;



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