summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-14 05:03:16 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-14 05:03:16 +0000
commit4b7ecb15d15864ffba2366e125be437960e83145 (patch)
treeb00295bcd47f10d5414b6b55921aa3b797f13bb8 /win32/win32.c
parent981f3b3db4f417db50c9162304d18242078874e8 (diff)
* time.c (search_time_t): support non 32bit time_t environments.
* win32/Makefile.sub (config.h): VC++8 has ``long long'' type. * win32/Makefile.sub (config.h): VC++8's time_t is 64bit value. * win32/win32.c (rb_w32_utime): drop read-only attribute before changing file time. all changes are backported from CVS HEAD. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9929 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 ce69f3b826..5bc1f5b245 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -3504,6 +3504,9 @@ rb_w32_utime(const char *path, 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) {
@@ -3517,6 +3520,8 @@ rb_w32_utime(const char *path, struct utimbuf *times)
}
CloseHandle(hFile);
}
+ if (attr != (DWORD)-1 && (attr & FILE_ATTRIBUTE_READONLY))
+ SetFileAttributes(path, attr);
});
return ret;