ruby-changes:37969
From: nobu <ko1@a...>
Date: Sun, 22 Mar 2015 11:26:20 +0900 (JST)
Subject: [ruby-changes:37969] nobu:r50050 (trunk): win32.c: stati64_handle
nobu 2015-03-22 11:23:21 +0900 (Sun, 22 Mar 2015) New Revision: 50050 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50050 Log: win32.c: stati64_handle * win32/win32.c (stati64_handle): extract from rb_w32_fstati64. Modified files: trunk/win32/win32.c Index: win32/win32.c =================================================================== --- win32/win32.c (revision 50049) +++ win32/win32.c (revision 50050) @@ -4869,6 +4869,7 @@ isUNCRoot(const WCHAR *path) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L4869 static time_t filetime_to_unixtime(const FILETIME *ft); static WCHAR *name_for_stat(WCHAR *buf, const WCHAR *path); +static DWORD stati64_handle(HANDLE h, struct stati64 *st); #undef fstat /* License: Ruby's */ @@ -4901,7 +4902,6 @@ rb_w32_fstat(int fd, struct stat *st) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L4902 int rb_w32_fstati64(int fd, struct stati64 *st) { - BY_HANDLE_FILE_INFORMATION info; struct stat tmp; int ret; @@ -4915,7 +4915,18 @@ rb_w32_fstati64(int fd, struct stati64 * https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L4915 tmp.st_mode &= ~(S_IWGRP | S_IWOTH); #endif COPY_STAT(tmp, *st, +); - if (GetFileInformationByHandle((HANDLE)_get_osfhandle(fd), &info)) { + stati64_handle((HANDLE)_get_osfhandle(fd), st); + return ret; +} + +/* License: Ruby's */ +static DWORD +stati64_handle(HANDLE h, struct stati64 *st) +{ + BY_HANDLE_FILE_INFORMATION info; + DWORD attr = (DWORD)-1; + + if (GetFileInformationByHandle(h, &info)) { #ifdef __BORLANDC__ if (!(info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) { st->st_mode |= S_IWUSR; @@ -4925,8 +4936,10 @@ rb_w32_fstati64(int fd, struct stati64 * https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L4936 st->st_atime = filetime_to_unixtime(&info.ftLastAccessTime); st->st_mtime = filetime_to_unixtime(&info.ftLastWriteTime); st->st_ctime = filetime_to_unixtime(&info.ftCreationTime); + st->st_nlink = info.nNumberOfLinks; + attr = info.dwFileAttributes; } - return ret; + return attr; } /* License: Ruby's */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/