Improve copy-file diagnostics on MS-Windows.
src/fileio.c (Fcopy_file) [WINDOWSNT]: Improve diagnostics when CopyFile fails by looking at what GetLastError returns.
This commit is contained in:
parent
c1fea2c0d2
commit
8d23a33120
2 changed files with 10 additions and 1 deletions
|
@ -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.
|
||||
(Bug#13298)
|
||||
(Fcopy_file) [WINDOWSNT]: Improve diagnostics when CopyFile fails.
|
||||
|
||||
* w32proc.c (reader_thread): Avoid passing NULL handles to
|
||||
SetEvent and WaitForSingleObject.
|
||||
|
|
10
src/fileio.c
10
src/fileio.c
|
@ -2029,7 +2029,15 @@ entries (depending on how Emacs was built). */)
|
|||
if (!CopyFile (SDATA (encoded_file),
|
||||
SDATA (encoded_newname),
|
||||
FALSE))
|
||||
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;
|
||||
else
|
||||
errno = EPERM;
|
||||
report_file_error ("Copying file", Fcons (file, Fcons (newname, Qnil)));
|
||||
}
|
||||
/* CopyFile retains the timestamp by default. */
|
||||
else if (NILP (keep_time))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue