xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 17958eeabf7c6367c452cffd9b59ce2010ded509

Add strerror(errno) to individual syscalls errors
Individual error messages when 'syscalls' is on lacked system error
string which is present when errors are aggregated at the end of an
operation.

Re-organize the code to reuse the same formatting code in both cases so
they won't diverge in the future.

Thanks to an anonymous at Vifm Q2A site.

See
https://q2a.vifm.info/1756/avoiding-excessive-error-dialogs-during-copy-move?show=1767#c1767
Author: xaizek
Author date (UTC): 2024-04-13 12:05
Committer name: xaizek
Committer date (UTC): 2024-04-14 12:13
Parent(s): 3faa653fbfb28c4df134c00a979f93ae7f164c86
Signing key: 99DC5E4DB05F6BE2
Tree: 6e5f466826f5d12da328d3b1dbcfccd0c204203a
File Lines added Lines deleted
ChangeLog 4 0
src/io/ioe.c 48 13
src/io/ioe.h 4 0
src/ops.c 1 1
File ChangeLog changed (mode: 100644) (index c4a25ed2f..ac855a558)
240 240 Fixed absolute paths not being completed when 'autocd' option is enabled. Fixed absolute paths not being completed when 'autocd' option is enabled.
241 241 Thanks to Taras Halturin (a.k.a. halturin). Thanks to Taras Halturin (a.k.a. halturin).
242 242
243 Fixed individual error messages when 'syscalls' is on lacking system error
244 string which is present when errors are aggregated at the end of an
245 operation. Thanks to an anonymous at Vifm Q2A site.
246
243 247 0.13-beta to 0.13 (2023-04-04) 0.13-beta to 0.13 (2023-04-04)
244 248
245 249 Made "withicase" and "withrcase" affect how files are sorted before Made "withicase" and "withrcase" affect how files are sorted before
File src/io/ioe.c changed (mode: 100644) (index fe58b02dc..941b51522)
26 26 #include "../utils/path.h" #include "../utils/path.h"
27 27 #include "private/ioe.h" #include "private/ioe.h"
28 28
29 static void print_err_to_buf(const ioe_err_t *err, vle_textbuf *str);
30
29 31 void void
30 32 ioe_errlst_init(ioe_errlst_t *elist) ioe_errlst_init(ioe_errlst_t *elist)
31 33 { {
 
... ... ioe_errlst_to_str(const ioe_errlst_t *elist)
63 65
64 66 for(i = 0U; i < elist->error_count; ++i) for(i = 0U; i < elist->error_count; ++i)
65 67 { {
66 const ioe_err_t *const err = &elist->errors[i];
67 const char *const path = replace_home_part(err->path);
68 if(err->error_code == IO_ERR_UNKNOWN)
69 {
70 vle_tb_append_linef(str, "%s: %s", path, err->msg);
71 }
72 else if(err->msg[0] == '\0')
73 {
74 vle_tb_append_linef(str, "%s: %s", path, strerror(err->error_code));
75 }
76 else
68 if(i > 0U)
77 69 { {
78 vle_tb_append_linef(str, "%s: %s (%s)", path, err->msg,
79 strerror(err->error_code));
70 vle_tb_append(str, "\n");
80 71 } }
72
73 print_err_to_buf(&elist->errors[i], str);
81 74 } }
82 75
83 76 return vle_tb_release(str); return vle_tb_release(str);
84 77 } }
85 78
79 char *
80 ioe_err_to_str(const ioe_err_t *err)
81 {
82 vle_textbuf *str = vle_tb_create();
83 if(str == NULL)
84 {
85 return NULL;
86 }
87
88 print_err_to_buf(err, str);
89 return vle_tb_release(str);
90 }
91
92 /* Formats error into a buffer without adding newline. */
93 static void
94 print_err_to_buf(const ioe_err_t *err, vle_textbuf *str)
95 {
96 const char *path = err->path;
97
98 char *tilde_path = make_tilde_path(path);
99 if(tilde_path != NULL)
100 {
101 path = tilde_path;
102 }
103
104 if(err->error_code == IO_ERR_UNKNOWN)
105 {
106 vle_tb_appendf(str, "%s: %s", path, err->msg);
107 }
108 else if(err->msg[0] == '\0')
109 {
110 vle_tb_appendf(str, "%s: %s", path, strerror(err->error_code));
111 }
112 else
113 {
114 vle_tb_appendf(str, "%s: %s (%s)", path, err->msg,
115 strerror(err->error_code));
116 }
117
118 free(tilde_path);
119 }
120
86 121 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
87 122 /* vim: set cinoptions+=t0 filetype=c : */ /* vim: set cinoptions+=t0 filetype=c : */
File src/io/ioe.h changed (mode: 100644) (index 83315d6ba..5a3e0893c)
... ... void ioe_errlst_free(ioe_errlst_t *elist);
86 86 * newly allocated string. */ * newly allocated string. */
87 87 char * ioe_errlst_to_str(const ioe_errlst_t *elist); char * ioe_errlst_to_str(const ioe_errlst_t *elist);
88 88
89 /* Converts a single error from I/O module into a string. Returns newly
90 * allocated string. */
91 char * ioe_err_to_str(const ioe_err_t *err);
92
89 93 #endif /* VIFM__IO__IOE_H__ */ #endif /* VIFM__IO__IOE_H__ */
90 94
91 95 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
File src/ops.c changed (mode: 100644) (index a034f7e59..dd214591c)
... ... dispatch_error(io_args_t *args, const ioe_err_t *err)
1213 1213 } }
1214 1214
1215 1215 title = format_str("Error while %s", curr_ops->descr); title = format_str("Error while %s", curr_ops->descr);
1216 msg = format_str("%s: %s", replace_home_part(err->path), err->msg);
1216 msg = ioe_err_to_str(err);
1217 1217
1218 1218 response = prompt_user(args, title, msg, responses); response = prompt_user(args, title, msg, responses);
1219 1219
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master