chdir back to the curdir after extracting
authorDana Jansens <danakj@orodu.net>
Tue, 29 May 2007 23:44:31 +0000 (23:44 +0000)
committerDana Jansens <danakj@orodu.net>
Tue, 29 May 2007 23:44:31 +0000 (23:44 +0000)
src/install.c

index 6439a177020409e7489feae413b52e34fe7edc16..7d1670028023eae7ca3cbc5e32b74eb0015cc084 100644 (file)
@@ -24,30 +24,10 @@ static gzFile gzf = NULL;
     gtk_widget_destroy(msgw);                                            \
 }
 
-static int gzopen_frontend(const char *path, int oflags, int mode)
-{
-    int fd;
-
-    if ((fd = open(path, oflags, mode)) < 0) return -1;
-    if (!(gzf = gzdopen(fd, "rb"))) return -1;
-    return 1;
-}
-
-static int gzclose_frontend(int nothing)
-{
-    g_return_val_if_fail(gzf != NULL, 0);
-    return gzclose(gzf);
-}
-
-static ssize_t gzread_frontend(int nothing, void *buf, size_t s)
-{
-    return gzread(gzf, buf, s);
-}
-
-static ssize_t gzwrite_frontend(int nothing, const void *buf, size_t s)
-{
-    return gzwrite(gzf, buf, s);
-}
+static int gzopen_frontend(const char *path, int oflags, int mode);
+static int gzclose_frontend(int nothing);
+static ssize_t gzread_frontend(int nothing, void *buf, size_t s);
+static ssize_t gzwrite_frontend(int nothing, const void *buf, size_t s);
 
 tartype_t funcs = {
     (openfunc_t) gzopen_frontend,
@@ -62,7 +42,7 @@ gboolean install_theme(char *path, char *theme)
     gchar *dest;
     gint r;
     gchar *glob;
-    GtkWidget *w;
+    gchar *curdir;
 
     dest = g_build_path(G_DIR_SEPARATOR_S, g_get_home_dir(), ".themes", NULL);
     r = mkdir(dest, 0777);
@@ -72,10 +52,12 @@ gboolean install_theme(char *path, char *theme)
                 dest, strerror(errno));
         return FALSE;
     }
+    curdir = g_get_current_dir();
     if (chdir(dest) == -1) {
         gtk_msg(GTK_MESSAGE_ERROR,
                 _("Unable to move to directory \"%s\": %s"),
                 dest, strerror(errno));
+        g_free(curdir);
         return FALSE;
     }
 
@@ -83,6 +65,8 @@ gboolean install_theme(char *path, char *theme)
         gtk_msg(GTK_MESSAGE_ERROR,
                 _("Unable to open the file \"%s\": %s"),
                 path, strerror(errno));
+        chdir(curdir);
+        g_free(curdir);
         return FALSE;
     }
 
@@ -97,14 +81,43 @@ gboolean install_theme(char *path, char *theme)
                 path, strerror(errno));
 
         g_free(dest);
+        chdir(curdir);
+        g_free(curdir);
         return FALSE;
     }
 
     gtk_msg(GTK_MESSAGE_INFO, _("%s was installed to %s"), theme, dest);
-    gtk_dialog_run(GTK_DIALOG(w));
-    gtk_widget_destroy(w);
 
     g_free(dest);
 
+    chdir(curdir);
+    g_free(curdir);
+
     return TRUE;
 }
+
+static int gzopen_frontend(const char *path, int oflags, int mode)
+{
+    int fd;
+
+    if ((fd = open(path, oflags, mode)) < 0) return -1;
+    if (!(gzf = gzdopen(fd, "rb"))) return -1;
+    return 1;
+}
+
+static int gzclose_frontend(int nothing)
+{
+    g_return_val_if_fail(gzf != NULL, 0);
+    return gzclose(gzf);
+}
+
+static ssize_t gzread_frontend(int nothing, void *buf, size_t s)
+{
+    return gzread(gzf, buf, s);
+}
+
+static ssize_t gzwrite_frontend(int nothing, const void *buf, size_t s)
+{
+    return gzwrite(gzf, buf, s);
+}
+