diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-22 02:23:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-22 02:23:21 +0000 |
commit | 8670fc560b5f58fe6f91e6e73cf02df5ea6bb6d7 (patch) | |
tree | 4e764e73a97d0f1bee4b084d0906f73f7bcadde0 | |
parent | c6985abdd175f7e10715990afbdc310796de1c43 (diff) | |
download | ruby-8670fc560b5f58fe6f91e6e73cf02df5ea6bb6d7.tar.gz |
win32.c: stati64_handle
* win32/win32.c (stati64_handle): extract from rb_w32_fstati64.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | win32/win32.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c index ec1ebe4210..7cd53df9db 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -4869,6 +4869,7 @@ isUNCRoot(const WCHAR *path) 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) 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 *st) 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 *st) 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 */ |