diff options
author | Bram Moolenaar <Bram@vim.org> | 2007-06-28 20:02:32 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2007-06-28 20:02:32 +0000 |
commit | 5386a123f5038d397848cc0183eda93c7c8b9d95 (patch) | |
tree | 6f81e637dfe5e0d71eb7dccd8c948e74d0c0942b /src/ex_cmds.c | |
parent | 7f51474324cf1a31284f291e7097d989522f9d45 (diff) |
updated for version 7.1-017v7.1.017
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r-- | src/ex_cmds.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 9c9f856507..5ca3dfd07d 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -2912,22 +2912,35 @@ not_writing() } /* - * Check if a buffer is read-only. Ask for overruling in a dialog. - * Return TRUE and give an error message when the buffer is readonly. + * Check if a buffer is read-only (either 'readonly' option is set or file is + * read-only). Ask for overruling in a dialog. Return TRUE and give an error + * message when the buffer is readonly. */ static int check_readonly(forceit, buf) int *forceit; buf_T *buf; { - if (!*forceit && buf->b_p_ro) + struct stat st; + + /* Handle a file being readonly when the 'readonly' option is set or when + * the file exists and permissions are read-only. + * We will send 0777 to check_file_readonly(), as the "perm" variable is + * important for device checks but not here. */ + if (!*forceit && (buf->b_p_ro + || (mch_stat((char *)buf->b_ffname, &st) >= 0 + && check_file_readonly(buf->b_ffname, 0777)))) { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) if ((p_confirm || cmdmod.confirm) && buf->b_fname != NULL) { char_u buff[IOSIZE]; - dialog_msg(buff, _("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"), + if (buf->b_p_ro) + dialog_msg(buff, _("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"), + buf->b_fname); + else + dialog_msg(buff, _("File permissions of \"%s\" are read-only.\nIt may still be possible to write it.\nDo you wish to try?"), buf->b_fname); if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) == VIM_YES) @@ -2941,9 +2954,14 @@ check_readonly(forceit, buf) } else #endif + if (buf->b_p_ro) EMSG(_(e_readonly)); + else + EMSG2(_("E505: \"%s\" is read-only (add ! to override)"), + buf->b_fname); return TRUE; } + return FALSE; } |