Sha256: 73b3ff21617c207ac02d8d270956b9d633e8ea32967aad5671423b8e2491d526

Contents?: true

Size: 691 Bytes

Versions: 68

Compression:

Stored size: 691 Bytes

Contents

#include <ruby.h>
#ifdef HAVE_RUBY_IO_H
#  include <ruby/io.h>
#else
#  include <stdio.h>
#  include <rubyio.h>
#endif

#if ! HAVE_RB_IO_T
#  define rb_io_t OpenFile
#endif

#ifdef GetReadFile
#  define FPTR_TO_FD(fptr) (fileno(GetReadFile(fptr)))
#else
#  if !HAVE_RB_IO_T || (RUBY_VERSION_MAJOR == 1 && RUBY_VERSION_MINOR == 8)
#    define FPTR_TO_FD(fptr) fileno(fptr->f)
#  else
#    define FPTR_TO_FD(fptr) fptr->fd
#  endif
#endif

static int my_fileno(VALUE io)
{
	rb_io_t *fptr;
	int fd;

	if (TYPE(io) != T_FILE)
		io = rb_convert_type(io, T_FILE, "IO", "to_io");
	GetOpenFile(io, fptr);
	fd = FPTR_TO_FD(fptr);

	if (fd < 0)
		rb_raise(rb_eIOError, "closed stream");
	return fd;
}

Version data entries

68 entries across 67 versions & 3 rubygems

Version Path
kgio-2.9.3 ext/kgio/my_fileno.h
raindrops-0.13.0 ext/raindrops/my_fileno.h
raindrops-0.12.0.5.g821b ext/raindrops/my_fileno.h
kgio-2.9.2 ext/kgio/my_fileno.h
kgio-2.9.1 ext/kgio/my_fileno.h
kgio-2.9.0.2.gf33a ext/kgio/my_fileno.h
kgio-2.9.0 ext/kgio/my_fileno.h
kgio-2.8.1 ext/kgio/my_fileno.h
raindrops-0.12.0 ext/raindrops/my_fileno.h
kgio-2.8.0.2.g30c1 ext/kgio/my_fileno.h
raindrops-0.11.0 ext/raindrops/my_fileno.h
kgio-2.8.0 ext/kgio/my_fileno.h
raindrops-0.10.0 ext/raindrops/my_fileno.h
raindrops-0.9.0 ext/raindrops/my_fileno.h
raindrops-0.8.1 ext/raindrops/my_fileno.h
raindrops-0.8.0.5.g71f8 ext/raindrops/my_fileno.h
kgio-2.7.4 ext/kgio/my_fileno.h
kgio-2.7.3 ext/kgio/my_fileno.h
kgio-2.7.2 ext/kgio/my_fileno.h
kgio-2.7.1 ext/kgio/my_fileno.h