aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2012-12-29 19:47:39 +0200
committerEli Zaretskii2012-12-29 19:47:39 +0200
commit8d23a331207808396cf7359314f506158900f024 (patch)
tree38ff404f4ed3a4ae290eaafb6eebd274c1e07b7c /src
parentc1fea2c0d236a152efdff96c019e23ce1b4b1095 (diff)
downloademacs-8d23a331207808396cf7359314f506158900f024.tar.gz
emacs-8d23a331207808396cf7359314f506158900f024.zip
Improve copy-file diagnostics on MS-Windows.
src/fileio.c (Fcopy_file) [WINDOWSNT]: Improve diagnostics when CopyFile fails by looking at what GetLastError returns.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog1
-rw-r--r--src/fileio.c10
2 files changed, 10 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f40f936d13a..e95df2b8953 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -3,6 +3,7 @@
3 * fileio.c (Fset_file_selinux_context, Fset_file_acl): Return t if 3 * fileio.c (Fset_file_selinux_context, Fset_file_acl): Return t if
4 file's SELinux context or ACLs successfully set, nil otherwise. 4 file's SELinux context or ACLs successfully set, nil otherwise.
5 (Bug#13298) 5 (Bug#13298)
6 (Fcopy_file) [WINDOWSNT]: Improve diagnostics when CopyFile fails.
6 7
7 * w32proc.c (reader_thread): Avoid passing NULL handles to 8 * w32proc.c (reader_thread): Avoid passing NULL handles to
8 SetEvent and WaitForSingleObject. 9 SetEvent and WaitForSingleObject.
diff --git a/src/fileio.c b/src/fileio.c
index 241775abec1..0e63e3f18d9 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2029,7 +2029,15 @@ entries (depending on how Emacs was built). */)
2029 if (!CopyFile (SDATA (encoded_file), 2029 if (!CopyFile (SDATA (encoded_file),
2030 SDATA (encoded_newname), 2030 SDATA (encoded_newname),
2031 FALSE)) 2031 FALSE))
2032 report_file_error ("Copying file", Fcons (file, Fcons (newname, Qnil))); 2032 {
2033 /* CopyFile doesn't set errno when it fails. By far the most
2034 "popular" reason is that the target is read-only. */
2035 if (GetLastError () == 5)
2036 errno = EACCES;
2037 else
2038 errno = EPERM;
2039 report_file_error ("Copying file", Fcons (file, Fcons (newname, Qnil)));
2040 }
2033 /* CopyFile retains the timestamp by default. */ 2041 /* CopyFile retains the timestamp by default. */
2034 else if (NILP (keep_time)) 2042 else if (NILP (keep_time))
2035 { 2043 {