Stricter error handling

This commit is contained in:
Pierre Pronchery 2011-07-29 00:47:39 +00:00
parent 86f1c74f9d
commit 04dda49f3a
7 changed files with 100 additions and 99 deletions

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Browser 0.1.4\n" "Project-Id-Version: Browser 0.1.4\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-07-29 02:45+0200\n" "POT-Creation-Date: 2011-07-29 02:47+0200\n"
"PO-Revision-Date: 2010-03-29 23:28+0200\n" "PO-Revision-Date: 2010-03-29 23:28+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: English\n" "Language-Team: English\n"
@ -702,64 +702,64 @@ msgstr ""
msgid "Usage: view file...\n" msgid "Usage: view file...\n"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:119 ../src/plugins/cvs.c:505 #: ../src/plugins/cvs.c:120 ../src/plugins/cvs.c:506
msgid "CVS" msgid "CVS"
msgstr "CVS" msgstr "CVS"
#: ../src/plugins/cvs.c:166 #: ../src/plugins/cvs.c:167
msgid "Root:" msgid "Root:"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:168 #: ../src/plugins/cvs.c:169
msgid "Repository:" msgid "Repository:"
msgstr "Repository:" msgstr "Repository:"
#: ../src/plugins/cvs.c:170 #: ../src/plugins/cvs.c:171
msgid "Tag:" msgid "Tag:"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:172 ../src/plugins/cvs.c:189 #: ../src/plugins/cvs.c:173 ../src/plugins/cvs.c:190
msgid "Request diff" msgid "Request diff"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:175 ../src/plugins/cvs.c:192 #: ../src/plugins/cvs.c:176 ../src/plugins/cvs.c:193
msgid "Update" msgid "Update"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:178 ../src/plugins/cvs.c:195 #: ../src/plugins/cvs.c:179 ../src/plugins/cvs.c:196
msgid "Commit" msgid "Commit"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:187 #: ../src/plugins/cvs.c:188
msgid "Revision:" msgid "Revision:"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:202 #: ../src/plugins/cvs.c:203
msgid "Add to CVS" msgid "Add to CVS"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:205 #: ../src/plugins/cvs.c:206
msgid "Run make" msgid "Run make"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:335 ../src/plugins/cvs.c:404 #: ../src/plugins/cvs.c:336 ../src/plugins/cvs.c:405
msgid "Not a CVS repository" msgid "Not a CVS repository"
msgstr "Kein CVS Inhalt" msgstr "Kein CVS Inhalt"
#: ../src/plugins/cvs.c:427 #: ../src/plugins/cvs.c:428
msgid "Not managed by CVS" msgid "Not managed by CVS"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:549 #: ../src/plugins/cvs.c:550
msgid "Running command..." msgid "Running command..."
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:742 #: ../src/plugins/cvs.c:743
#, c-format #, c-format
msgid "Command exited with error code %d" msgid "Command exited with error code %d"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:748 #: ../src/plugins/cvs.c:749
#, c-format #, c-format
msgid "Command exited with signal %d" msgid "Command exited with signal %d"
msgstr "" msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Browser 0.1.4\n" "Project-Id-Version: Browser 0.1.4\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-07-29 02:45+0200\n" "POT-Creation-Date: 2011-07-29 02:47+0200\n"
"PO-Revision-Date: 2010-03-30 01:04+0200\n" "PO-Revision-Date: 2010-03-30 01:04+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: Spanish\n" "Language-Team: Spanish\n"
@ -702,64 +702,64 @@ msgstr ""
msgid "Usage: view file...\n" msgid "Usage: view file...\n"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:119 ../src/plugins/cvs.c:505 #: ../src/plugins/cvs.c:120 ../src/plugins/cvs.c:506
msgid "CVS" msgid "CVS"
msgstr "CVS" msgstr "CVS"
#: ../src/plugins/cvs.c:166 #: ../src/plugins/cvs.c:167
msgid "Root:" msgid "Root:"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:168 #: ../src/plugins/cvs.c:169
msgid "Repository:" msgid "Repository:"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:170 #: ../src/plugins/cvs.c:171
msgid "Tag:" msgid "Tag:"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:172 ../src/plugins/cvs.c:189 #: ../src/plugins/cvs.c:173 ../src/plugins/cvs.c:190
msgid "Request diff" msgid "Request diff"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:175 ../src/plugins/cvs.c:192 #: ../src/plugins/cvs.c:176 ../src/plugins/cvs.c:193
msgid "Update" msgid "Update"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:178 ../src/plugins/cvs.c:195 #: ../src/plugins/cvs.c:179 ../src/plugins/cvs.c:196
msgid "Commit" msgid "Commit"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:187 #: ../src/plugins/cvs.c:188
msgid "Revision:" msgid "Revision:"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:202 #: ../src/plugins/cvs.c:203
msgid "Add to CVS" msgid "Add to CVS"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:205 #: ../src/plugins/cvs.c:206
msgid "Run make" msgid "Run make"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:335 ../src/plugins/cvs.c:404 #: ../src/plugins/cvs.c:336 ../src/plugins/cvs.c:405
msgid "Not a CVS repository" msgid "Not a CVS repository"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:427 #: ../src/plugins/cvs.c:428
msgid "Not managed by CVS" msgid "Not managed by CVS"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:549 #: ../src/plugins/cvs.c:550
msgid "Running command..." msgid "Running command..."
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:742 #: ../src/plugins/cvs.c:743
#, c-format #, c-format
msgid "Command exited with error code %d" msgid "Command exited with error code %d"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:748 #: ../src/plugins/cvs.c:749
#, c-format #, c-format
msgid "Command exited with signal %d" msgid "Command exited with signal %d"
msgstr "" msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Browser 0.1.4\n" "Project-Id-Version: Browser 0.1.4\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-07-29 02:45+0200\n" "POT-Creation-Date: 2011-07-29 02:47+0200\n"
"PO-Revision-Date: 2010-03-29 23:28+0200\n" "PO-Revision-Date: 2010-03-29 23:28+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: French\n" "Language-Team: French\n"
@ -736,64 +736,64 @@ msgstr "Impossible d'éditer le fichier"
msgid "Usage: view file...\n" msgid "Usage: view file...\n"
msgstr "Usage: view fichier...\n" msgstr "Usage: view fichier...\n"
#: ../src/plugins/cvs.c:119 ../src/plugins/cvs.c:505 #: ../src/plugins/cvs.c:120 ../src/plugins/cvs.c:506
msgid "CVS" msgid "CVS"
msgstr "CVS" msgstr "CVS"
#: ../src/plugins/cvs.c:166 #: ../src/plugins/cvs.c:167
msgid "Root:" msgid "Root:"
msgstr "Racine :" msgstr "Racine :"
#: ../src/plugins/cvs.c:168 #: ../src/plugins/cvs.c:169
msgid "Repository:" msgid "Repository:"
msgstr "Dépôt :" msgstr "Dépôt :"
#: ../src/plugins/cvs.c:170 #: ../src/plugins/cvs.c:171
msgid "Tag:" msgid "Tag:"
msgstr "Tag :" msgstr "Tag :"
#: ../src/plugins/cvs.c:172 ../src/plugins/cvs.c:189 #: ../src/plugins/cvs.c:173 ../src/plugins/cvs.c:190
msgid "Request diff" msgid "Request diff"
msgstr "Différences" msgstr "Différences"
#: ../src/plugins/cvs.c:175 ../src/plugins/cvs.c:192 #: ../src/plugins/cvs.c:176 ../src/plugins/cvs.c:193
msgid "Update" msgid "Update"
msgstr "Actualiser" msgstr "Actualiser"
#: ../src/plugins/cvs.c:178 ../src/plugins/cvs.c:195 #: ../src/plugins/cvs.c:179 ../src/plugins/cvs.c:196
msgid "Commit" msgid "Commit"
msgstr "Soumettre" msgstr "Soumettre"
#: ../src/plugins/cvs.c:187 #: ../src/plugins/cvs.c:188
msgid "Revision:" msgid "Revision:"
msgstr "Révision :" msgstr "Révision :"
#: ../src/plugins/cvs.c:202 #: ../src/plugins/cvs.c:203
msgid "Add to CVS" msgid "Add to CVS"
msgstr "Ajouter à CVS" msgstr "Ajouter à CVS"
#: ../src/plugins/cvs.c:205 #: ../src/plugins/cvs.c:206
msgid "Run make" msgid "Run make"
msgstr "Exécuter make" msgstr "Exécuter make"
#: ../src/plugins/cvs.c:335 ../src/plugins/cvs.c:404 #: ../src/plugins/cvs.c:336 ../src/plugins/cvs.c:405
msgid "Not a CVS repository" msgid "Not a CVS repository"
msgstr "Pas un dépôt CVS" msgstr "Pas un dépôt CVS"
#: ../src/plugins/cvs.c:427 #: ../src/plugins/cvs.c:428
msgid "Not managed by CVS" msgid "Not managed by CVS"
msgstr "Pas maintenu par CVS" msgstr "Pas maintenu par CVS"
#: ../src/plugins/cvs.c:549 #: ../src/plugins/cvs.c:550
msgid "Running command..." msgid "Running command..."
msgstr "Exécution en cours..." msgstr "Exécution en cours..."
#: ../src/plugins/cvs.c:742 #: ../src/plugins/cvs.c:743
#, c-format #, c-format
msgid "Command exited with error code %d" msgid "Command exited with error code %d"
msgstr "La commande a terminé avec le code d'erreur %d" msgstr "La commande a terminé avec le code d'erreur %d"
#: ../src/plugins/cvs.c:748 #: ../src/plugins/cvs.c:749
#, c-format #, c-format
msgid "Command exited with signal %d" msgid "Command exited with signal %d"
msgstr "La commande a été terminée par le signal %d" msgstr "La commande a été terminée par le signal %d"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Browser 0.1.4\n" "Project-Id-Version: Browser 0.1.4\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-07-29 02:45+0200\n" "POT-Creation-Date: 2011-07-29 02:47+0200\n"
"PO-Revision-Date: 2010-04-07 23:18+0200\n" "PO-Revision-Date: 2010-04-07 23:18+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: Italian\n" "Language-Team: Italian\n"
@ -702,64 +702,64 @@ msgstr ""
msgid "Usage: view file...\n" msgid "Usage: view file...\n"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:119 ../src/plugins/cvs.c:505 #: ../src/plugins/cvs.c:120 ../src/plugins/cvs.c:506
msgid "CVS" msgid "CVS"
msgstr "CVS" msgstr "CVS"
#: ../src/plugins/cvs.c:166 #: ../src/plugins/cvs.c:167
msgid "Root:" msgid "Root:"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:168 #: ../src/plugins/cvs.c:169
msgid "Repository:" msgid "Repository:"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:170 #: ../src/plugins/cvs.c:171
msgid "Tag:" msgid "Tag:"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:172 ../src/plugins/cvs.c:189 #: ../src/plugins/cvs.c:173 ../src/plugins/cvs.c:190
msgid "Request diff" msgid "Request diff"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:175 ../src/plugins/cvs.c:192 #: ../src/plugins/cvs.c:176 ../src/plugins/cvs.c:193
msgid "Update" msgid "Update"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:178 ../src/plugins/cvs.c:195 #: ../src/plugins/cvs.c:179 ../src/plugins/cvs.c:196
msgid "Commit" msgid "Commit"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:187 #: ../src/plugins/cvs.c:188
msgid "Revision:" msgid "Revision:"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:202 #: ../src/plugins/cvs.c:203
msgid "Add to CVS" msgid "Add to CVS"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:205 #: ../src/plugins/cvs.c:206
msgid "Run make" msgid "Run make"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:335 ../src/plugins/cvs.c:404 #: ../src/plugins/cvs.c:336 ../src/plugins/cvs.c:405
msgid "Not a CVS repository" msgid "Not a CVS repository"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:427 #: ../src/plugins/cvs.c:428
msgid "Not managed by CVS" msgid "Not managed by CVS"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:549 #: ../src/plugins/cvs.c:550
msgid "Running command..." msgid "Running command..."
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:742 #: ../src/plugins/cvs.c:743
#, c-format #, c-format
msgid "Command exited with error code %d" msgid "Command exited with error code %d"
msgstr "" msgstr ""
#: ../src/plugins/cvs.c:748 #: ../src/plugins/cvs.c:749
#, c-format #, c-format
msgid "Command exited with signal %d" msgid "Command exited with signal %d"
msgstr "" msgstr ""

View File

@ -261,7 +261,7 @@ Browser * browser_new(char const * directory)
if((browser = malloc(sizeof(*browser))) == NULL) if((browser = malloc(sizeof(*browser))) == NULL)
{ {
browser_error(NULL, directory != NULL ? directory : ".", 0); browser_error(NULL, directory != NULL ? directory : ".", 1);
return NULL; return NULL;
} }
browser->window = NULL; browser->window = NULL;
@ -281,7 +281,7 @@ Browser * browser_new(char const * directory)
if((browser->config = config_new()) == NULL if((browser->config = config_new()) == NULL
|| browser_config_load(browser) != 0) || browser_config_load(browser) != 0)
browser_error(browser, _("Error while loading configuration"), browser_error(browser, _("Error while loading configuration"),
0); 1);
/* mime */ /* mime */
browser->mime = mime_new(NULL); /* FIXME share MIME instances */ browser->mime = mime_new(NULL); /* FIXME share MIME instances */
@ -702,7 +702,6 @@ static void _error_response(gpointer data);
int browser_error(Browser * browser, char const * message, int ret) int browser_error(Browser * browser, char const * message, int ret)
{ {
GtkWidget * dialog; GtkWidget * dialog;
char const * error;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s(\"%s\", %d) errno=%d\n", __func__, message, fprintf(stderr, "DEBUG: %s(\"%s\", %d) errno=%d\n", __func__, message,
@ -710,7 +709,6 @@ int browser_error(Browser * browser, char const * message, int ret)
#endif #endif
if(browser == NULL) if(browser == NULL)
return _browser_error(message, ret); return _browser_error(message, ret);
error = strerror(errno);
dialog = gtk_message_dialog_new(GTK_WINDOW(browser->window), dialog = gtk_message_dialog_new(GTK_WINDOW(browser->window),
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE, GTK_BUTTONS_CLOSE,
@ -718,7 +716,7 @@ int browser_error(Browser * browser, char const * message, int ret)
"%s", _("Error")); "%s", _("Error"));
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
#endif #endif
"%s: %s", message, error); "%s", message);
gtk_window_set_title(GTK_WINDOW(dialog), _("Error")); gtk_window_set_title(GTK_WINDOW(dialog), _("Error"));
if(ret < 0) if(ret < 0)
{ {
@ -735,8 +733,7 @@ int browser_error(Browser * browser, char const * message, int ret)
static int _browser_error(char const * message, int ret) static int _browser_error(char const * message, int ret)
{ {
fputs("browser: ", stderr); fprintf(stderr, "%s: %s", "browser", message);
perror(message);
return ret; return ret;
} }
@ -944,13 +941,13 @@ void browser_open_with(Browser * browser, char const * path)
if(filename == NULL) if(filename == NULL)
return; return;
if((pid = fork()) == -1) if((pid = fork()) == -1)
browser_error(browser, "fork", 0); browser_error(browser, strerror(errno), 1);
else if(pid == 0) else if(pid == 0)
{ {
if(close(0) != 0) if(close(0) != 0)
browser_error(NULL, "stdin", 0); browser_error(NULL, strerror(errno), 0);
execlp(filename, filename, path, NULL); execlp(filename, filename, path, NULL);
browser_error(NULL, filename, 0); browser_error(NULL, strerror(errno), 0);
exit(2); exit(2);
} }
g_free(filename); g_free(filename);
@ -970,7 +967,7 @@ void browser_refresh(Browser * browser)
if(browser->current == NULL) if(browser->current == NULL)
return; return;
if((dir = _browser_opendir(browser->current->data, &st)) == NULL) if((dir = _browser_opendir(browser->current->data, &st)) == NULL)
browser_error(browser, browser->current->data, 0); browser_error(browser, strerror(errno), 1);
else else
_browser_refresh_do(browser, dir, &st); _browser_refresh_do(browser, dir, &st);
} }
@ -1028,7 +1025,7 @@ static int _refresh_new_loop(Browser * browser)
if((path = g_build_filename(browser->current->data, de->d_name, NULL)) if((path = g_build_filename(browser->current->data, de->d_name, NULL))
== NULL || lstat(path, &lst) != 0) == NULL || lstat(path, &lst) != 0)
{ {
browser_error(NULL, de->d_name, 0); browser_error(NULL, strerror(errno), 1);
if(path != NULL) if(path != NULL)
g_free(path); g_free(path);
return 0; return 0;
@ -1341,7 +1338,8 @@ static gboolean _done_timeout(gpointer data)
if(stat(browser->current->data, &st) != 0) if(stat(browser->current->data, &st) != 0)
{ {
browser->refresh_id = 0; browser->refresh_id = 0;
return browser_error(NULL, browser->current->data, FALSE); browser_error(NULL, strerror(errno), 1);
return FALSE;
} }
if(st.st_mtime == browser->refresh_mti) if(st.st_mtime == browser->refresh_mti)
return TRUE; return TRUE;
@ -1402,7 +1400,7 @@ static int _current_loop(Browser * browser)
if((path = g_build_filename(browser->current->data, de->d_name, NULL)) if((path = g_build_filename(browser->current->data, de->d_name, NULL))
== NULL || lstat(path, &lst) != 0) == NULL || lstat(path, &lst) != 0)
{ {
browser_error(NULL, de->d_name, 0); browser_error(NULL, strerror(errno), 1);
if(path != NULL) if(path != NULL)
g_free(path); g_free(path);
return 0; return 0;
@ -1553,7 +1551,7 @@ void browser_set_location(Browser * browser, char const * path)
} }
else else
/* XXX errno may not be set */ /* XXX errno may not be set */
browser_error(browser, realpath, 0); browser_error(browser, strerror(errno), 1);
free(realpath); free(realpath);
} }

View File

@ -122,12 +122,12 @@ void on_file_new_folder(gpointer data)
len = strlen(cur) + strlen(newfolder) + 2; len = strlen(cur) + strlen(newfolder) + 2;
if((path = malloc(len)) == NULL) if((path = malloc(len)) == NULL)
{ {
browser_error(browser, "malloc", 0); browser_error(browser, strerror(errno), 1);
return; return;
} }
snprintf(path, len, "%s/%s", cur, newfolder); snprintf(path, len, "%s/%s", cur, newfolder);
if(mkdir(path, 0777) != 0) if(mkdir(path, 0777) != 0)
browser_error(browser, path, 0); browser_error(browser, strerror(errno), 1);
free(path); free(path);
} }
@ -138,7 +138,7 @@ void on_file_new_symlink(gpointer data)
char const * cur = browser->current->data; char const * cur = browser->current->data;
if(_common_symlink(browser->window, cur) != 0) if(_common_symlink(browser->window, cur) != 0)
browser_error(browser, "symlink", 0); browser_error(browser, strerror(errno), 1);
} }
@ -205,7 +205,7 @@ void on_edit_delete(gpointer data)
} }
if(res == GTK_RESPONSE_YES if(res == GTK_RESPONSE_YES
&& _common_exec("delete", "-ir", selection) != 0) && _common_exec("delete", "-ir", selection) != 0)
browser_error(browser, "fork", 0); browser_error(browser, strerror(errno), 1);
g_list_foreach(selection, (GFunc)free, NULL); g_list_foreach(selection, (GFunc)free, NULL);
g_list_free(selection); g_list_free(selection);
} }
@ -405,7 +405,7 @@ void on_properties(gpointer data)
if((selection = _copy_selection(browser)) == NULL) if((selection = _copy_selection(browser)) == NULL)
selection = g_list_append(NULL, strdup(browser->current->data)); selection = g_list_append(NULL, strdup(browser->current->data));
if(_common_exec("properties", NULL, selection) != 0) if(_common_exec("properties", NULL, selection) != 0)
browser_error(browser, "fork", 0); browser_error(browser, strerror(errno), 1);
g_list_foreach(selection, (GFunc)free, NULL); g_list_foreach(selection, (GFunc)free, NULL);
g_list_free(selection); g_list_free(selection);
} }
@ -544,7 +544,7 @@ void on_filename_edited(GtkCellRendererText * renderer, gchar * arg1,
{ {
q = g_filename_from_utf8(p, -1, NULL, NULL, NULL); q = g_filename_from_utf8(p, -1, NULL, NULL, NULL);
if(rename(path, (q != NULL) ? q : p) != 0) if(rename(path, (q != NULL) ? q : p) != 0)
browser_error(browser, path, 0); browser_error(browser, strerror(errno), 1);
else else
gtk_list_store_set(browser->store, &iter, BR_COL_PATH, gtk_list_store_set(browser->store, &iter, BR_COL_PATH,
p, BR_COL_DISPLAY_NAME, arg2, -1); p, BR_COL_DISPLAY_NAME, arg2, -1);
@ -553,11 +553,11 @@ void on_filename_edited(GtkCellRendererText * renderer, gchar * arg1,
else if(lstat(path, &st) == 0 && S_ISLNK(st.st_mode)) else if(lstat(path, &st) == 0 && S_ISLNK(st.st_mode))
{ {
if(rename(path, p) != 0) if(rename(path, p) != 0)
browser_error(browser, path, 0); browser_error(browser, strerror(errno), 1);
} }
/* FIXME implement workaround for FAT */ /* FIXME implement workaround for FAT */
else if(link(path, p) != 0 || unlink(path) != 0) else if(link(path, p) != 0 || unlink(path) != 0)
browser_error(browser, path, 0); browser_error(browser, strerror(errno), 1);
free(p); free(p);
free(path); free(path);
} }
@ -618,7 +618,7 @@ void on_view_drag_data_received(GtkWidget * widget, GdkDragContext * context,
BR_COL_PATH, &dest, -1); BR_COL_PATH, &dest, -1);
} }
if(_common_drag_data_received(context, seldata, dest) != 0) if(_common_drag_data_received(context, seldata, dest) != 0)
browser_error(browser, "fork", 0); browser_error(browser, strerror(errno), 1);
} }
#endif /* GTK_CHECK_VERSION(2, 8, 0) */ #endif /* GTK_CHECK_VERSION(2, 8, 0) */
@ -831,12 +831,12 @@ static void _on_popup_new_text_file(gpointer data)
len = strlen(cur) + strlen(newtext) + 2; len = strlen(cur) + strlen(newtext) + 2;
if((path = malloc(len)) == NULL) if((path = malloc(len)) == NULL)
{ {
browser_error(browser, "malloc", 0); browser_error(browser, strerror(errno), 1);
return; return;
} }
snprintf(path, len, "%s/%s", cur, newtext); snprintf(path, len, "%s/%s", cur, newtext);
if((fd = creat(path, 0666)) < 0) if((fd = creat(path, 0666)) < 0)
browser_error(browser, path, 0); browser_error(browser, strerror(errno), 1);
else else
close(fd); close(fd);
free(path); free(path);
@ -1034,13 +1034,12 @@ static void _on_icon_run(gpointer data)
dialog = gtk_message_dialog_new(GTK_WINDOW(cb->browser->window), dialog = gtk_message_dialog_new(GTK_WINDOW(cb->browser->window),
GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING,
GTK_BUTTONS_YES_NO, "%s", GTK_BUTTONS_YES_NO,
#if GTK_CHECK_VERSION(2, 6, 0) #if GTK_CHECK_VERSION(2, 6, 0)
_("Warning")); "%s", _("Warning"));
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
"%s",
#endif #endif
_("Are you sure you want to execute this file?")); "%s", _("Are you sure you want to execute this file?"));
gtk_window_set_title(GTK_WINDOW(dialog), _("Warning")); gtk_window_set_title(GTK_WINDOW(dialog), _("Warning"));
res = gtk_dialog_run(GTK_DIALOG(dialog)); res = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);
@ -1048,7 +1047,10 @@ static void _on_icon_run(gpointer data)
return; return;
argv[0] = cb->path; argv[0] = cb->path;
if(g_spawn_async(NULL, argv, NULL, 0, NULL, NULL, NULL, &error) != TRUE) if(g_spawn_async(NULL, argv, NULL, 0, NULL, NULL, NULL, &error) != TRUE)
browser_error(cb->browser, cb->path, 1); {
browser_error(cb->browser, error->message, 1);
g_error_free(error);
}
} }
static void _on_icon_open_with(gpointer data) static void _on_icon_open_with(gpointer data)
@ -1080,7 +1082,7 @@ static void _on_icon_unmount(gpointer data)
#else #else
if(unmount(cb->path, 0) != 0) if(unmount(cb->path, 0) != 0)
#endif #endif
browser_error(cb->browser, cb->path, 0); browser_error(cb->browser, strerror(errno), 1);
} }
@ -1132,12 +1134,12 @@ static void _paste_selection(Browser * browser)
if(browser->selection_cut != 1) if(browser->selection_cut != 1)
{ {
if(_common_exec("copy", "-ir", browser->selection) != 0) if(_common_exec("copy", "-ir", browser->selection) != 0)
browser_error(browser, "fork", 0); browser_error(browser, strerror(errno), 1);
browser->selection = g_list_remove(browser->selection, p); browser->selection = g_list_remove(browser->selection, p);
return; return;
} }
if(_common_exec("move", "-i", browser->selection) != 0) if(_common_exec("move", "-i", browser->selection) != 0)
browser_error(browser, "fork", 0); browser_error(browser, strerror(errno), 1);
browser->selection = g_list_remove(browser->selection, p); browser->selection = g_list_remove(browser->selection, p);
g_list_foreach(browser->selection, (GFunc)free, NULL); g_list_foreach(browser->selection, (GFunc)free, NULL);
g_list_free(browser->selection); g_list_free(browser->selection);

View File

@ -20,6 +20,7 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h>
#include <libintl.h> #include <libintl.h>
#include "Browser.h" #include "Browser.h"
#define _(string) gettext(string) #define _(string) gettext(string)
@ -479,7 +480,7 @@ static int _cvs_add_task(BrowserPlugin * plugin, char const * title,
GtkWidget * widget; GtkWidget * widget;
if((p = realloc(cvs->tasks, sizeof(*p) * (cvs->tasks_cnt + 1))) == NULL) if((p = realloc(cvs->tasks, sizeof(*p) * (cvs->tasks_cnt + 1))) == NULL)
return -helper->error(helper->browser, "malloc", 1); return -helper->error(helper->browser, strerror(errno), 1);
cvs->tasks = p; cvs->tasks = p;
if((task = object_new(sizeof(*task))) == NULL) if((task = object_new(sizeof(*task))) == NULL)
return -helper->error(helper->browser, error_get(), 1); return -helper->error(helper->browser, error_get(), 1);