Mercurial > emacs
diff src/fileio.c @ 43792:8bb81d691271
(Fcopy_file) [WINDOWS_NT]: Ensure file is not
read-only when setting modified time.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Sat, 09 Mar 2002 00:35:13 +0000 |
parents | d12db931f164 |
children | b1abfedc2e1d |
line wrap: on
line diff
--- a/src/fileio.c Fri Mar 08 21:08:19 2002 +0000 +++ b/src/fileio.c Sat Mar 09 00:35:13 2002 +0000 @@ -2409,12 +2409,25 @@ 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);