New error symbol 'permission-denied'
* src/fileio.c (syms_of_fileio) <permission-denied>: Define the symbol and its 'err-conditions' and 'error-message' properties. (get_file_errno_data): Return permission-denied on EACCES. * test/src/filelock-tests.el (filelock-tests-file-locked-p-spoiled) (filelock-tests-unlock-spoiled) (filelock-tests-kill-buffer-spoiled): Adapt the tests to the new error symbol. * doc/lispref/errors.texi (Standard Errors): * etc/NEWS: Document 'permission-denied' error.
This commit is contained in:
parent
8f82a83cae
commit
cc63704815
4 changed files with 24 additions and 4 deletions
|
@ -98,6 +98,10 @@ Lisp reader, not to file I/O@. @xref{Input Functions}.
|
|||
@item file-already-exists
|
||||
This is a subcategory of @code{file-error}. @xref{Writing to Files}.
|
||||
|
||||
@item permission-denied
|
||||
This is a subcategory of @code{file-error}, which occurs when the OS
|
||||
doesn't allow Emacs to access a file or a directory for some reason.
|
||||
|
||||
@item file-date-error
|
||||
This is a subcategory of @code{file-error}. It occurs when
|
||||
@code{copy-file} tries and fails to set the last-modification time of
|
||||
|
|
6
etc/NEWS
6
etc/NEWS
|
@ -1186,6 +1186,12 @@ The events 'touchscreen-begin, 'touchscreen-update', and
|
|||
'touchscreen-end' have been added to take better advantage of
|
||||
touch-capable display panels.
|
||||
|
||||
+++
|
||||
** New error symbol 'permission-denied'.
|
||||
This is a subcategory of 'file-error', and is signaled when some file
|
||||
operation fails because the OS doesn't allow Emacs to access a file or
|
||||
a directory.
|
||||
|
||||
|
||||
* Changes in Emacs 29.1 on Non-Free Operating Systems
|
||||
|
||||
|
|
12
src/fileio.c
12
src/fileio.c
|
@ -195,7 +195,11 @@ get_file_errno_data (char const *string, Lisp_Object name, int errorno)
|
|||
if (errorno == EEXIST)
|
||||
return Fcons (Qfile_already_exists, errdata);
|
||||
else
|
||||
return Fcons (errorno == ENOENT ? Qfile_missing : Qfile_error,
|
||||
return Fcons (errorno == ENOENT
|
||||
? Qfile_missing
|
||||
: (errorno == EACCES
|
||||
? Qpermission_denied
|
||||
: Qfile_error),
|
||||
Fcons (build_string (string), errdata));
|
||||
}
|
||||
|
||||
|
@ -6380,6 +6384,7 @@ syms_of_fileio (void)
|
|||
DEFSYM (Qfile_already_exists, "file-already-exists");
|
||||
DEFSYM (Qfile_date_error, "file-date-error");
|
||||
DEFSYM (Qfile_missing, "file-missing");
|
||||
DEFSYM (Qpermission_denied, "permission-denied");
|
||||
DEFSYM (Qfile_notify_error, "file-notify-error");
|
||||
DEFSYM (Qremote_file_error, "remote-file-error");
|
||||
DEFSYM (Qexcl, "excl");
|
||||
|
@ -6438,6 +6443,11 @@ behaves as if file names were encoded in `utf-8'. */);
|
|||
Fput (Qfile_missing, Qerror_message,
|
||||
build_pure_c_string ("File is missing"));
|
||||
|
||||
Fput (Qpermission_denied, Qerror_conditions,
|
||||
Fpurecopy (list3 (Qpermission_denied, Qfile_error, Qerror)));
|
||||
Fput (Qpermission_denied, Qerror_message,
|
||||
build_pure_c_string ("Cannot access file or directory"));
|
||||
|
||||
Fput (Qfile_notify_error, Qerror_conditions,
|
||||
Fpurecopy (list3 (Qfile_notify_error, Qfile_error, Qerror)));
|
||||
Fput (Qfile_notify_error, Qerror_message,
|
||||
|
|
|
@ -123,7 +123,7 @@ the case)."
|
|||
(filelock-tests--spoil-lock-file buffer-file-truename)
|
||||
(let ((err (should-error (file-locked-p (buffer-file-name)))))
|
||||
(should (equal (seq-subseq err 0 2)
|
||||
'(file-error "Testing file lock")))))))
|
||||
'(permission-denied "Testing file lock")))))))
|
||||
|
||||
(ert-deftest filelock-tests-unlock-spoiled ()
|
||||
"Check that `unlock-buffer' fails if the lockfile is \"spoiled\"."
|
||||
|
@ -144,7 +144,7 @@ the case)."
|
|||
(lambda (err) (push err errors))))
|
||||
(unlock-buffer))
|
||||
(should (consp errors))
|
||||
(should (equal '(file-error "Unlocking file")
|
||||
(should (equal '(permission-denied "Unlocking file")
|
||||
(seq-subseq (car errors) 0 2)))
|
||||
(should (equal (length errors) 1))))))
|
||||
|
||||
|
@ -174,7 +174,7 @@ the case)."
|
|||
(lambda (err) (push err errors))))
|
||||
(kill-buffer))
|
||||
(should (consp errors))
|
||||
(should (equal '(file-error "Unlocking file")
|
||||
(should (equal '(permission-denied "Unlocking file")
|
||||
(seq-subseq (car errors) 0 2)))
|
||||
(should (equal (length errors) 1))))))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue