diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-04-08 13:28:13 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-08 13:28:13 +0900 |
commit | 9e6e39c3512f7a962c44dc3729c98a0f8be90341 (patch) | |
tree | 901a22676d54d78240e450b64a8cd06eb1703910 /file.c | |
parent | 5ac4bf2cd87e1eb5779ca5ae7f96a1a22e8436d9 (diff) |
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
Notes
Notes:
Merged-By: shyouhei <shyouhei@ruby-lang.org>
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -11,7 +11,7 @@ **********************************************************************/ -#include "ruby/config.h" +#include "ruby/3/config.h" #ifdef _WIN32 # include "missing/file.h" @@ -682,7 +682,21 @@ rb_stat_mode(VALUE self) static VALUE rb_stat_nlink(VALUE self) { - return UINT2NUM(get_stat(self)->st_nlink); + /* struct stat::st_nlink is nlink_t in POSIX. Not the case for Windows. */ + const struct stat *ptr = get_stat(self); + + if (sizeof(ptr->st_nlink) <= sizeof(int)) { + return UINT2NUM((unsigned)ptr->st_nlink); + } + else if (sizeof(ptr->st_nlink) == sizeof(long)) { + return ULONG2NUM((unsigned long)ptr->st_nlink); + } + else if (sizeof(ptr->st_nlink) == sizeof(LONG_LONG)) { + return ULL2NUM((unsigned LONG_LONG)ptr->st_nlink); + } + else { + rb_bug(":FIXME: don't know what to do"); + } } /* |