aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/save-attachments/ChangeLog5
-rw-r--r--plugins/save-attachments/save-attachments.c19
2 files changed, 18 insertions, 6 deletions
diff --git a/plugins/save-attachments/ChangeLog b/plugins/save-attachments/ChangeLog
index 3ab5a8a8a8..599381eba1 100644
--- a/plugins/save-attachments/ChangeLog
+++ b/plugins/save-attachments/ChangeLog
@@ -1,3 +1,8 @@
+2005-12-17 Tor Lillqvist <tml@novell.com>
+
+ * save-attachments.c (entry_changed): Use GLib API to manipulate
+ pathname.
+
2005-05-16 Not Zed <NotZed@Ximian.com>
* save-attachments.c: moved e-error to e-util
diff --git a/plugins/save-attachments/save-attachments.c b/plugins/save-attachments/save-attachments.c
index 4ecd7e5943..bc4dc89a6c 100644
--- a/plugins/save-attachments/save-attachments.c
+++ b/plugins/save-attachments/save-attachments.c
@@ -30,6 +30,11 @@
#include <glib.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+
+#if !GLIB_CHECK_VERSION (2, 8, 0)
+#define g_access access
+#endif
#include <gtk/gtkcheckbutton.h>
#include <gtk/gtkdialog.h>
@@ -220,7 +225,7 @@ save_part(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, void *d)
* the POSIX access-call should suffice for checking the file existence.
*/
- if (access(save, F_OK) == 0)
+ if (g_access(save, F_OK) == 0)
doit = e_error_run(NULL, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, save, NULL) == GTK_RESPONSE_OK;
if (doit)
@@ -271,20 +276,22 @@ static void
entry_changed(GtkWidget *entry, struct _save_data *data)
{
char *path;
+ char *basename = NULL;
const char *file;
- struct stat st;
path = gnome_file_entry_get_full_path((GnomeFileEntry *)data->entry, FALSE);
if (path == NULL
- || (file = strrchr(path, '/')) == NULL
- || file[1] == 0
- || (stat(path, &st) == 0 && S_ISDIR(st.st_mode)))
+ || G_IS_DIR_SEPARATOR (path[strlen(path)-1])
+ || (basename = g_path_get_basename(path)) == NULL
+ || (basename[0] == '.' && basename[1] == '\0')
+ || (g_file_test(path, G_FILE_TEST_IS_DIR)))
file = "attachment";
else
- file++;
+ file = basename;
gtk_tree_model_foreach((GtkTreeModel *)data->model, entry_changed_update, (void *)file);
g_free(path);
+ g_free(basename);
}
static void