diff options
author | Jason Rumney <[email protected]> | 2002-03-09 00:38:54 +0000 |
---|---|---|
committer | Jason Rumney <[email protected]> | 2002-03-09 00:38:54 +0000 |
commit | ad497129bafbe28df203d8a5bc309daa6d2ae646 (patch) | |
tree | fdbea91491d57816d683f3a7140ef6c0518d3555 /src/fileio.c | |
parent | f67acc8dfbd37fd8d7bb8ab34dbad942b5b32513 (diff) |
(Fcopy_file) [WINDOWS_NT]: Ensure file is not
read-only when setting modified time.
Diffstat (limited to 'src/fileio.c')
-rw-r--r-- | src/fileio.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/fileio.c b/src/fileio.c index d328a2d363..bb39f2a153 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2409,12 +2409,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); |