diff --git a/ChangeLog b/ChangeLog index a852ed8860..92e482d872 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Aug 4 02:34:05 2003 NAKAMURA Usaku + + * win32/win32.c (rb_w32_utime): never use utime() of C runtime. + [ruby-talk:77782] + Sun Aug 3 23:56:50 2003 Nobuyoshi Nakada * eval.c (rb_call_super): should propagate previous block for diff --git a/win32/win32.c b/win32/win32.c index b871bafd62..7527d29706 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -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; }