summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Rumney <jasonr@gnu.org>2002-03-09 00:45:25 +0000
committerJason Rumney <jasonr@gnu.org>2002-03-09 00:45:25 +0000
commit1cb508e56f961cd073d6ca33eddf60bd1bcddc3c (patch)
tree5ed594e68452527bba9a85dbb794675663d567bb
parent5a44f67ba3c825ed0a127ed7207d2023c1f376a9 (diff)
downloademacs-1cb508e56f961cd073d6ca33eddf60bd1bcddc3c.tar.gz
(Fcopy_file) [WINDOWS_NT]: Ensure file is not
read-only when setting modified time.
-rw-r--r--src/ChangeLog5
-rw-r--r--src/fileio.c23
2 files changed, 23 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7f5c1aed680..d4a0af2eb88 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2002-03-09 Jason Rumney <jasonr@gnu.org>
+
+ * fileio.c (Fcopy_file) [WINDOWS_NT]: Ensure file is not
+ read-only when setting modified time.
+
2002-03-08 Juanma Barranquero <jbarranquero@peoplecall.com>
* w32fns.c (Fx_display_color_cells): Force 24+ bit color depths to
diff --git a/src/fileio.c b/src/fileio.c
index b152f0a74e0..12c064cb34a 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2342,12 +2342,25 @@ A prefix arg makes KEEP-TIME non-nil.")
else if (NILP (keep_time))
{
EMACS_TIME now;
+ DWORD attributes;
+ char * filename;
+
EMACS_GET_TIME (now);
- if (set_file_times (XSTRING (encoded_newname)->data,
- now, now))
- Fsignal (Qfile_date_error,
- Fcons (build_string ("Cannot set file date"),
- Fcons (newname, Qnil)));
+ filename = XSTRING (encoded_newname)->data;
+
+ /* Ensure file is writable while its modified time is set. */
+ attributes = GetFileAttributes (filename);
+ SetFileAttributes (filename, attributes ^ FILE_ATTRIBUTE_READONLY);
+ if (set_file_times (filename, now, now))
+ {
+ /* Restore original attributes. */
+ SetFileAttributes (filename, attributes);
+ Fsignal (Qfile_date_error,
+ Fcons (build_string ("Cannot set file date"),
+ Fcons (newname, Qnil)));
+ }
+ /* Restore original attributes. */
+ SetFileAttributes (filename, attributes);
}
#else /* not WINDOWSNT */
ifd = emacs_open (XSTRING (encoded_file)->data, O_RDONLY, 0);