@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
'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.
+
\f
* Changes in Emacs 29.1 on Non-Free Operating Systems
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));
}
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");
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,
(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\"."
(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))))))
(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))))))