[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master cc63704: New error symbol 'permission-denied'
From: |
Eli Zaretskii |
Subject: |
master cc63704: New error symbol 'permission-denied' |
Date: |
Sun, 19 Dec 2021 10:30:41 -0500 (EST) |
branch: master
commit cc63704815ee4ae686a0cf86e12f7f2596dd22a3
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
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.
---
doc/lispref/errors.texi | 4 ++++
etc/NEWS | 6 ++++++
src/fileio.c | 12 +++++++++++-
test/src/filelock-tests.el | 6 +++---
4 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/doc/lispref/errors.texi b/doc/lispref/errors.texi
index f848218..9dd052c 100644
--- a/doc/lispref/errors.texi
+++ b/doc/lispref/errors.texi
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index 862621a..24f3da8 100644
--- a/etc/NEWS
+++ b/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
diff --git a/src/fileio.c b/src/fileio.c
index a0563cc..f802e4e 100644
--- a/src/fileio.c
+++ b/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,
diff --git a/test/src/filelock-tests.el b/test/src/filelock-tests.el
index ba00167..2d682e2 100644
--- a/test/src/filelock-tests.el
+++ b/test/src/filelock-tests.el
@@ -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))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master cc63704: New error symbol 'permission-denied',
Eli Zaretskii <=