mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* win32/win32.c (rb_w32_utime): never use utime() of C runtime.
[ruby-talk:77782] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
096f7a4c89
commit
381ff05505
2 changed files with 21 additions and 15 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Aug 4 02:34:05 2003 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* win32/win32.c (rb_w32_utime): never use utime() of C runtime.
|
||||
[ruby-talk:77782]
|
||||
|
||||
Sun Aug 3 23:56:50 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_call_super): should propagate previous block for
|
||||
|
|
|
@ -3178,7 +3178,7 @@ unixtime_to_filetime(time_t time, FILETIME *ft)
|
|||
int
|
||||
rb_w32_utime(const char *path, struct utimbuf *times)
|
||||
{
|
||||
HANDLE hDir;
|
||||
HANDLE hFile;
|
||||
SYSTEMTIME st;
|
||||
FILETIME atime, mtime;
|
||||
struct tm *tm;
|
||||
|
@ -3188,9 +3188,6 @@ rb_w32_utime(const char *path, struct utimbuf *times)
|
|||
if (rb_w32_stat(path, &stat)) {
|
||||
return -1;
|
||||
}
|
||||
if (!(stat.st_mode & S_IFDIR) || IsWin95()) {
|
||||
return utime(path, times);
|
||||
}
|
||||
|
||||
if (unixtime_to_filetime(times->actime, &atime)) {
|
||||
return -1;
|
||||
|
@ -3199,17 +3196,21 @@ rb_w32_utime(const char *path, struct utimbuf *times)
|
|||
return -1;
|
||||
}
|
||||
|
||||
hDir = CreateFile(path, GENERIC_WRITE, 0, 0, OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS, 0);
|
||||
if (hDir == INVALID_HANDLE_VALUE) {
|
||||
errno = map_errno();
|
||||
return -1;
|
||||
}
|
||||
if (!SetFileTime(hDir, NULL, &atime, &mtime)) {
|
||||
errno = map_errno();
|
||||
ret = -1;
|
||||
}
|
||||
CloseHandle(hDir);
|
||||
RUBY_CRITICAL({
|
||||
hFile = CreateFile(path, GENERIC_WRITE, 0, 0, OPEN_EXISTING,
|
||||
IsWin95() ? 0 : FILE_FLAG_BACKUP_SEMANTICS, 0);
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
errno = map_errno();
|
||||
ret = -1;
|
||||
}
|
||||
else {
|
||||
if (!SetFileTime(hFile, NULL, &atime, &mtime)) {
|
||||
errno = map_errno();
|
||||
ret = -1;
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue