Commit 8d23a331 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Improve copy-file diagnostics on MS-Windows.

 src/fileio.c (Fcopy_file) [WINDOWSNT]: Improve diagnostics when CopyFile
 fails by looking at what GetLastError returns.
parent c1fea2c0
......@@ -3,6 +3,7 @@
* fileio.c (Fset_file_selinux_context, Fset_file_acl): Return t if
file's SELinux context or ACLs successfully set, nil otherwise.
(Fcopy_file) [WINDOWSNT]: Improve diagnostics when CopyFile fails.
* w32proc.c (reader_thread): Avoid passing NULL handles to
SetEvent and WaitForSingleObject.
......@@ -2029,7 +2029,15 @@ entries (depending on how Emacs was built). */)
if (!CopyFile (SDATA (encoded_file),
SDATA (encoded_newname),
report_file_error ("Copying file", Fcons (file, Fcons (newname, Qnil)));
/* CopyFile doesn't set errno when it fails. By far the most
"popular" reason is that the target is read-only. */
if (GetLastError () == 5)
errno = EACCES;
errno = EPERM;
report_file_error ("Copying file", Fcons (file, Fcons (newname, Qnil)));
/* CopyFile retains the timestamp by default. */
else if (NILP (keep_time))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment