summaryrefslogtreecommitdiffstats
path: root/win32/win32.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-14 04:49:01 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-14 04:49:01 +0000
commit08f4115be60057f9ad410a70a07970352b80224e (patch)
treee0c59f4b7f399c1b8a6e1c9376c6e7345d90e49f /win32/win32.c
parent0be560f42a5b8f05a6a292eaba31e5937c0d3780 (diff)
downloadruby-08f4115be60057f9ad410a70a07970352b80224e.tar.gz
ruby-08f4115be60057f9ad410a70a07970352b80224e.tar.xz
ruby-08f4115be60057f9ad410a70a07970352b80224e.zip
* win32/win32.c (rb_w32_utime): drop read-only attribute before
changing file time. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c
index b1c6197ec..973a795c4 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -3871,6 +3871,9 @@ rb_w32_utime(const char *path, const struct utimbuf *times)
}
RUBY_CRITICAL({
+ const DWORD attr = GetFileAttributes(path);
+ if (attr != (DWORD)-1 && (attr & FILE_ATTRIBUTE_READONLY))
+ SetFileAttributes(path, attr & ~FILE_ATTRIBUTE_READONLY);
hFile = CreateFile(path, GENERIC_WRITE, 0, 0, OPEN_EXISTING,
IsWin95() ? 0 : FILE_FLAG_BACKUP_SEMANTICS, 0);
if (hFile == INVALID_HANDLE_VALUE) {
@@ -3884,6 +3887,8 @@ rb_w32_utime(const char *path, const struct utimbuf *times)
}
CloseHandle(hFile);
}
+ if (attr != (DWORD)-1 && (attr & FILE_ATTRIBUTE_READONLY))
+ SetFileAttributes(path, attr);
});
return ret;