* file.c (rb_io_statfs, rb_statfs_init, statfs_inspect): fix
  compilation errors on Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-04-28 14:10:28 +00:00
Родитель 19fac4432f
Коммит a76b0ed54d
1 изменённых файлов: 18 добавлений и 14 удалений

32
file.c
Просмотреть файл

@ -71,13 +71,20 @@ int flock(int, int);
#endif #endif
#ifdef HAVE_STRUCT_STATFS #ifdef HAVE_STRUCT_STATFS
typedef struct statfs statfs_t; typedef struct statfs statfs_t;
#define STATFS(f, s) statfs((f), (s))
#elif defined(HAVE_STRUCT_STATVFS) #elif defined(HAVE_STRUCT_STATVFS)
typedef struct statvfs statfs_t; typedef struct statvfs statfs_t;
#define STATFS(f, s) statvfs((f), (s))
#else #else
# define WITHOUT_STATFS # define WITHOUT_STATFS
#endif #endif
#ifndef WITHOUT_STATFS #ifndef WITHOUT_STATFS
static VALUE rb_statfs_new(const statfs_t *st); static VALUE rb_statfs_new(const statfs_t *st);
#if defined(HAVE_FSTATFS)
#define FSTATFS(f, s) Fstatfs((f), (s))
#elif !defined(HAVE_FSTATVFS)
#define FSTATFS(f, s) Fstatvfs((f), (s))
#endif
#endif #endif
#if defined(__native_client__) && defined(NACL_NEWLIB) #if defined(__native_client__) && defined(NACL_NEWLIB)
@ -122,8 +129,9 @@ static VALUE rb_statfs_new(const statfs_t *st);
#define unlink(p) rb_w32_uunlink(p) #define unlink(p) rb_w32_uunlink(p)
#undef rename #undef rename
#define rename(f, t) rb_w32_urename((f), (t)) #define rename(f, t) rb_w32_urename((f), (t))
#undef statfs #undef STATFS
#define statfs(f, s) ustatfs((f), (s)) #define STATFS(f, s) ustatfs((f), (s))
#define HAVE_STATFS 1
#else #else
#define STAT(p, s) stat((p), (s)) #define STAT(p, s) stat((p), (s))
#endif #endif
@ -1130,16 +1138,16 @@ rb_io_statfs(VALUE obj)
#if !defined(HAVE_FSTATFS) && !defined(HAVE_FSTATVFS) #if !defined(HAVE_FSTATFS) && !defined(HAVE_FSTATVFS)
VALUE path; VALUE path;
#endif #endif
int ret;
GetOpenFile(obj, fptr); GetOpenFile(obj, fptr);
#ifdef HAVE_FSTATFS #if defined(HAVE_FSTATFS) || defined(HAVE_FSTATVFS)
if (fstatfs(fptr->fd, &st) == -1) ret = FSTATFS(fptr->fd, &st);
#elif defined(HAVE_FSTATVFS)
if (fstatvfs(fptr->fd, &st) == -1)
#else #else
if (statfs(StringValueCStr(rb_str_encode_ospath(fptr->pathv)), &st) == -1) path = rb_str_encode_ospath(fptr->pathv);
ret = STATFS(StringValueCStr(path), &st);
#endif #endif
{ if (ret == -1) {
rb_sys_fail_path(fptr->pathv); rb_sys_fail_path(fptr->pathv);
} }
return rb_statfs_new(&st); return rb_statfs_new(&st);
@ -5401,11 +5409,7 @@ rb_statfs_init(VALUE obj, VALUE fname)
rb_secure(2); rb_secure(2);
FilePathValue(fname); FilePathValue(fname);
fname = rb_str_encode_ospath(fname); fname = rb_str_encode_ospath(fname);
#ifdef HAVE_FSTATFS if (STATFS(StringValueCStr(fname), &st) == -1) {
if (statfs(StringValueCStr(fname), &st) == -1) {
#elif HAVE_FSTATVFS
if (statvfs(StringValueCStr(fname), &st) == -1) {
#endif
rb_sys_fail_path(fname); rb_sys_fail_path(fname);
} }
if (DATA_PTR(obj)) { if (DATA_PTR(obj)) {
@ -5598,7 +5602,7 @@ statfs_inspect(VALUE self)
", files=%"PRI_LL_PREFIX"d/%"PRI_LL_PREFIX"d" ", files=%"PRI_LL_PREFIX"d/%"PRI_LL_PREFIX"d"
">", ">",
rb_obj_class(self), rb_obj_class(self),
#ifdef HAVE_STRUCT_STATFS #ifdef HAVE_STRUCT_STATFS_F_TYPE
(long)st->f_type, (long)st->f_type,
#endif #endif
#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME) #if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME)