diff --git a/lib/widget/wtools.c b/lib/widget/wtools.c index 3a8ab55f1..7e9d57549 100644 --- a/lib/widget/wtools.c +++ b/lib/widget/wtools.c @@ -435,12 +435,16 @@ message (int flags, const char *title, const char *text, ...) /** Show error message box */ gboolean -mc_error_message (GError ** mcerror) +mc_error_message (GError ** mcerror, int *code) { if (mcerror == NULL || *mcerror == NULL) return FALSE; message (D_ERROR, MSG_ERROR, _("%d: %s"), (*mcerror)->code, (*mcerror)->message); + + if (code != NULL) + *code = (*mcerror)->code; + g_error_free (*mcerror); *mcerror = NULL; diff --git a/lib/widget/wtools.h b/lib/widget/wtools.h index 17db5a190..8585eb828 100644 --- a/lib/widget/wtools.h +++ b/lib/widget/wtools.h @@ -84,7 +84,7 @@ struct WDialog *create_message (int flags, const char *title, void message (int flags, const char *title, const char *text, ...) __attribute__ ((format (__printf__, 3, 4))); -gboolean mc_error_message (GError ** mcerror); +gboolean mc_error_message (GError ** mcerror, int *code); status_msg_t *status_msg_create (const char *title, double delay, status_msg_cb init_cb, status_msg_update_cb update_cb, status_msg_cb deinit_cb); diff --git a/src/filemanager/boxes.c b/src/filemanager/boxes.c index 81440172e..6aa5a36ca 100644 --- a/src/filemanager/boxes.c +++ b/src/filemanager/boxes.c @@ -166,7 +166,7 @@ skin_apply (const gchar * skin_override) panel_init (); repaint_screen (); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/filemanager/ext.c b/src/filemanager/ext.c index e21827be7..2fa9ae50c 100644 --- a/src/filemanager/ext.c +++ b/src/filemanager/ext.c @@ -965,7 +965,7 @@ regex_command_for (void *target, const vfs_path_t * filename_vpath, const char * p += 2; found = regex_check_type (filename_vpath, p, case_insense, &have_type, &mcerror); - if (mc_error_message (&mcerror)) + if (mc_error_message (&mcerror, NULL)) error_flag = TRUE; /* leave it if file cannot be opened */ } else if (strncmp (p, "default/", 8) == 0) diff --git a/src/filemanager/hotlist.c b/src/filemanager/hotlist.c index 18cbd9ce8..f77298245 100644 --- a/src/filemanager/hotlist.c +++ b/src/filemanager/hotlist.c @@ -1472,7 +1472,7 @@ load_hotlist (void) if (!mc_config_save_file (mc_main_config, &mcerror)) setup_save_config_show_error (mc_main_config->ini_path, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); } stat (hotlist_file_name, &stat_buf); diff --git a/src/main.c b/src/main.c index a08a8f0b8..9b5a8fa1c 100644 --- a/src/main.c +++ b/src/main.c @@ -378,7 +378,7 @@ main (int argc, char *argv[]) if (mc_global.mc_run_mode == MC_RUN_FULL) command_set_default_colors (); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); #ifdef ENABLE_SUBSHELL /* Done here to ensure that the subshell doesn't */ diff --git a/src/vfs/sftpfs/vfs_class.c b/src/vfs/sftpfs/vfs_class.c index d88cd4c92..f9048bc12 100644 --- a/src/vfs/sftpfs/vfs_class.c +++ b/src/vfs/sftpfs/vfs_class.c @@ -155,7 +155,7 @@ sftpfs_cb_open (const vfs_path_t * vpath, int flags, mode_t mode) if (!sftpfs_open_file (file_handler, flags, mode, &mcerror)) { - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); g_free (file_handler); return NULL; } @@ -184,7 +184,7 @@ sftpfs_cb_opendir (const vfs_path_t * vpath) tty_got_interrupt (); ret_value = sftpfs_opendir (vpath, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return ret_value; } @@ -209,7 +209,7 @@ sftpfs_cb_readdir (void *data) } sftpfs_dirent = sftpfs_readdir (data, &mcerror); - if (!mc_error_message (&mcerror)) + if (!mc_error_message (&mcerror, NULL)) { if (sftpfs_dirent != NULL) vfs_print_message (_("sftp: (Ctrl-G break) Listing... %s"), sftpfs_dirent->dent.d_name); @@ -235,7 +235,7 @@ sftpfs_cb_closedir (void *data) GError *mcerror = NULL; rc = sftpfs_closedir (data, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } @@ -255,7 +255,7 @@ sftpfs_cb_lstat (const vfs_path_t * vpath, struct stat *buf) GError *mcerror = NULL; rc = sftpfs_lstat (vpath, buf, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } @@ -275,7 +275,7 @@ sftpfs_cb_stat (const vfs_path_t * vpath, struct stat *buf) GError *mcerror = NULL; rc = sftpfs_stat (vpath, buf, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } @@ -295,7 +295,7 @@ sftpfs_cb_fstat (void *data, struct stat *buf) GError *mcerror = NULL; rc = sftpfs_fstat (data, buf, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } @@ -316,7 +316,7 @@ sftpfs_cb_readlink (const vfs_path_t * vpath, char *buf, size_t size) GError *mcerror = NULL; rc = sftpfs_readlink (vpath, buf, size, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } @@ -354,7 +354,7 @@ sftpfs_cb_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2) GError *mcerror = NULL; rc = sftpfs_symlink (vpath1, vpath2, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } @@ -440,7 +440,7 @@ sftpfs_cb_read (void *data, char *buffer, size_t count) } rc = sftpfs_read_file (fh, buffer, count, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } @@ -462,7 +462,7 @@ sftpfs_cb_write (void *data, const char *buf, size_t nbyte) vfs_file_handler_t *fh = (vfs_file_handler_t *) data; rc = sftpfs_write_file (fh, buf, nbyte, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } @@ -489,7 +489,7 @@ sftpfs_cb_close (void *data) vfs_stamp_create (&sftpfs_class, super); rc = sftpfs_close_file (file_handler, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); if (file_handler->handle != -1) close (file_handler->handle); @@ -516,7 +516,7 @@ sftpfs_cb_chmod (const vfs_path_t * vpath, mode_t mode) GError *mcerror = NULL; rc = sftpfs_chmod (vpath, mode, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } @@ -536,7 +536,7 @@ sftpfs_cb_mkdir (const vfs_path_t * vpath, mode_t mode) GError *mcerror = NULL; rc = sftpfs_mkdir (vpath, mode, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } @@ -555,7 +555,7 @@ sftpfs_cb_rmdir (const vfs_path_t * vpath) GError *mcerror = NULL; rc = sftpfs_rmdir (vpath, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } @@ -577,7 +577,7 @@ sftpfs_cb_lseek (void *data, off_t offset, int whence) GError *mcerror = NULL; ret_offset = sftpfs_lseek (file_handler, offset, whence, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return ret_offset; } @@ -596,7 +596,7 @@ sftpfs_cb_unlink (const vfs_path_t * vpath) GError *mcerror = NULL; rc = sftpfs_unlink (vpath, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } @@ -616,7 +616,7 @@ sftpfs_cb_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2) GError *mcerror = NULL; rc = sftpfs_rename (vpath1, vpath2, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return rc; } diff --git a/src/vfs/sftpfs/vfs_subclass.c b/src/vfs/sftpfs/vfs_subclass.c index 718281be1..33abb5ab0 100644 --- a/src/vfs/sftpfs/vfs_subclass.c +++ b/src/vfs/sftpfs/vfs_subclass.c @@ -109,9 +109,9 @@ sftpfs_cb_open_connection (struct vfs_s_super *super, super->path_element = vfs_path_element_clone (vpath_element); sftpfs_fill_connection_data_from_config (super, &mcerror); - if (mc_error_message (&mcerror)) + if (mc_error_message (&mcerror, &ret_value)) { - vpath_element->class->verrno = mcerror->code; + vpath_element->class->verrno = ret_value; return -1; } @@ -121,7 +121,7 @@ sftpfs_cb_open_connection (struct vfs_s_super *super, vfs_s_default_stat (vpath_element->class, S_IFDIR | 0755)); ret_value = sftpfs_open_connection (super, &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); return ret_value; } @@ -140,7 +140,7 @@ sftpfs_cb_close_connection (struct vfs_class *me, struct vfs_s_super *super) (void) me; sftpfs_close_connection (super, "Normal Shutdown", &mcerror); - mc_error_message (&mcerror); + mc_error_message (&mcerror, NULL); g_free (super->data); }