From fe12fb0f627d4311c2f5dbba1b7b91afdad379ab Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 29 May 2007 23:44:31 +0000 Subject: [PATCH] chdir back to the curdir after extracting --- src/install.c | 67 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/src/install.c b/src/install.c index 6439a17..7d16700 100644 --- a/src/install.c +++ b/src/install.c @@ -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); +} + -- 2.39.2