[Xfce4-commits] <libxfce4ui:master> Test if working directory exists.

Nick Schermer noreply at xfce.org
Sun Mar 14 21:30:02 CET 2010


Updating branch refs/heads/master
         to 7b83b640103b47982b2e43831e893c16b722843b (commit)
       from 62d8a75cf5bef10d0645ad0f156461760cf96e9a (commit)

commit 7b83b640103b47982b2e43831e893c16b722843b
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Mar 14 21:23:29 2010 +0100

    Test if working directory exists.
    
    Else the "Failed to change to directory" warning will show in
    the console without and nothing will be spawned.

 libxfce4ui/xfce-spawn.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/libxfce4ui/xfce-spawn.c b/libxfce4ui/xfce-spawn.c
index 4dc2eb2..731ffb2 100644
--- a/libxfce4ui/xfce-spawn.c
+++ b/libxfce4ui/xfce-spawn.c
@@ -47,6 +47,8 @@
 #include <libsn/sn.h>
 #endif
 
+#include <glib/gstdio.h>
+#include <libxfce4util/libxfce4util.h>
 #include <libxfce4ui/xfce-spawn.h>
 #include <libxfce4ui/xfce-gdk-extensions.h>
 #include <libxfce4ui/libxfce4ui-private.h>
@@ -393,6 +395,20 @@ xfce_spawn_on_screen_with_child_watch (GdkScreen    *screen,
   if (child_watch_closure != NULL)
     flags |= G_SPAWN_DO_NOT_REAP_CHILD;
 
+  /* test if the working directory exists */
+  if (working_directory == NULL || *working_directory == '\0')
+    {
+      /* not worth a warning */
+      working_directory = NULL;
+    }
+  else if (!g_file_test (working_directory, G_FILE_TEST_IS_DIR))
+    {
+      /* print warning for user */
+      g_printerr (_("Working directory \"%s\" does not exist. It won't be used "
+                    "when spawning \"%s\"."), working_directory, *argv);
+      working_directory = NULL;
+    }
+
   /* try to spawn the new process */
   succeed = g_spawn_async (working_directory, argv, cenvp, flags, NULL,
                            NULL, &pid, error);



More information about the Xfce4-commits mailing list