diff --git a/misc/clifmrc b/misc/clifmrc index ea43f6a4..25032382 100644 --- a/misc/clifmrc +++ b/misc/clifmrc @@ -374,6 +374,7 @@ # confirmation prompts. Each field has two values separated by a colon (':'). # The left value indicates the command (for the time being only the following # left values are supported): +# 'o': overwrite files (mostly 'c' and 'm' commands) # 'r': remove ('r' command) # 't': trash ('t' command) # 'R': bulk rename ('br' command) @@ -383,7 +384,7 @@ # 'y' or 'n'. # If unset (or set to any other value), no default answer will be used. # For example, to set 'n' as the default answer for the 'r' command and -# trash, and 'y' for everything else: "r:n,t:n,d:y". +# 'overwrite files', and 'y' for everything else: "r:n,o:n,d:y". ;DefaultAnswer="" # How should the 'l' command create symbolic links. Possible values: diff --git a/src/bulk_rename.c b/src/bulk_rename.c index 2668ff92..7ea0859d 100644 --- a/src/bulk_rename.c +++ b/src/bulk_rename.c @@ -92,7 +92,7 @@ rename_file(char *oldpath, char *newpath) if (lstat(npath, &a) == 0) { xerror("br: '%s': %s\n", newpath, strerror(EEXIST)); if (rl_get_y_or_n(_("Overwrite this file?"), - conf.default_answer.remove) == 0) { + conf.default_answer.overwrite) == 0) { free(npath); return EEXIST; } @@ -380,7 +380,7 @@ check_dups(FILE *fp) free(fnames); if (dups > 0 && rl_get_y_or_n(_("Continue?"), - conf.default_answer.remove) == 0) { + conf.default_answer.overwrite) == 0) { return dups; } diff --git a/src/config.c b/src/config.c index 7700794d..447a0aef 100644 --- a/src/config.c +++ b/src/config.c @@ -3019,6 +3019,7 @@ set_default_answer(const char *str) switch (*str) { case 'd': conf.default_answer.default_ = str[2]; break; case 'D': conf.default_answer.default_all = str[2]; break; + case 'o': conf.default_answer.overwrite = str[2]; break; case 'r': conf.default_answer.remove = str[2]; break; case 'R': conf.default_answer.bulk_rename = str[2]; break; case 't': conf.default_answer.trash = str[2]; break; diff --git a/src/file_operations.c b/src/file_operations.c index 66bf4767..0ea940ab 100644 --- a/src/file_operations.c +++ b/src/file_operations.c @@ -1350,7 +1350,7 @@ symlink_file(char **args) if (lstat(link_name, &a) != -1 && S_ISLNK(a.st_mode)) { printf("link: '%s': %s\n", link_name, strerror(EEXIST)); if (rl_get_y_or_n(_("Overwrite this file?"), - conf.default_answer.remove) == 0) { + conf.default_answer.overwrite) == 0) { return FUNC_SUCCESS; } @@ -1694,7 +1694,7 @@ check_overwrite(char **args, const int force, size_t *skipped) if (p && lstat(p, &a) != -1) { snprintf(msg, sizeof(msg), "%s: '%s': Overwrite this file?", cmd_name, p); - if (rl_get_y_or_n(msg, conf.default_answer.remove) == 0) { + if (rl_get_y_or_n(msg, conf.default_answer.overwrite) == 0) { free(p); return 0; } @@ -1730,7 +1730,7 @@ check_overwrite(char **args, const int force, size_t *skipped) snprintf(msg, sizeof(msg), "%s: '%s': Overwrite this file?", cmd_name, buf); - if (rl_get_y_or_n(msg, conf.default_answer.remove) == 0) { + if (rl_get_y_or_n(msg, conf.default_answer.overwrite) == 0) { /* Nullify this entry. It will be skipped later. */ *args[i] = '\0'; (*skipped)++; diff --git a/src/helpers.h b/src/helpers.h index df13ea08..74a8d633 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -1101,9 +1101,10 @@ struct default_answer_t { char remove; char trash; char bulk_rename; + char overwrite; char default_; char default_all; - char pad[3]; + char pad[2]; }; /* User settings (mostly from the config file) */ diff --git a/src/init.c b/src/init.c index abf8d994..29dbe6be 100644 --- a/src/init.c +++ b/src/init.c @@ -195,6 +195,7 @@ init_conf_struct(void) conf.default_answer.remove = DEF_ANSWER_REMOVE; conf.default_answer.trash = DEF_ANSWER_TRASH; conf.default_answer.bulk_rename = DEF_ANSWER_BULK_RENAME; + conf.default_answer.overwrite = DEF_ANSWER_OVERWRITE; conf.default_answer.default_ = DEF_ANSWER_DEFAULT; conf.default_answer.default_all = DEF_ANSWER_DEFAULT_ALL; conf.desktop_notifications = UNSET; diff --git a/src/settings.h b/src/settings.h index 376a5a65..ca2d05de 100644 --- a/src/settings.h +++ b/src/settings.h @@ -464,9 +464,10 @@ ws2=31:ws3=38;5;228:ws4=32:ws5=36:ws6=38;5;214:ws7=35:ws8=2;37:xf=1;31:xs=32:" /* Default options */ /* Default answers for confirmation prompts: 0 (none), 'y', or 'n' */ -#define DEF_ANSWER_REMOVE 0 -#define DEF_ANSWER_TRASH 0 -#define DEF_ANSWER_BULK_RENAME 0 +#define DEF_ANSWER_REMOVE 0 /* 'r' command */ +#define DEF_ANSWER_TRASH 0 /* 't' command */ +#define DEF_ANSWER_BULK_RENAME 0 /* 'br' command */ +#define DEF_ANSWER_OVERWRITE 0 /* 'c' and 'm' commands mostly */ #define DEF_ANSWER_DEFAULT 0 /* Remaining prompts */ #define DEF_ANSWER_DEFAULT_ALL 0 /* All prompts (overrides the above ones) */