summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-22 02:23:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-22 02:23:21 +0000
commit8670fc560b5f58fe6f91e6e73cf02df5ea6bb6d7 (patch)
tree4e764e73a97d0f1bee4b084d0906f73f7bcadde0 /win32/win32.c
parentc6985abdd175f7e10715990afbdc310796de1c43 (diff)
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
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c19
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 */