Project

General

Profile

Feature #936 ยป nread.diff

OlegPuchinin (Oleg Puchinin), 12/27/2008 08:30 PM

View differences:

ruby/io.c 2008-12-27 17:23:27.000000000 +0600
1322 1322
    return INT2FIX(fd);
1323 1323
}
1324 1324

  
1325
static VALUE
1326
rb_io_nread(VALUE io) // --gc
1327
{
1328
	rb_io_t *fptr;
1329
	int fd;
1330
	int ret = -1;
1331

  
1332
	GetOpenFile(io, fptr);
1333
	fd = fptr->fd;
1334
	if (ioctl (fd, FIONREAD, &ret) != 0)
1335
		return INT2FIX(-1);
1336

  
1337
	return INT2FIX(ret);
1338
}
1325 1339

  
1326 1340
/*
1327 1341
 *  call-seq:
......
8593 8607
    rb_define_method(rb_cIO, "sysread",  rb_io_sysread, -1);
8594 8608

  
8595 8609
    rb_define_method(rb_cIO, "fileno", rb_io_fileno, 0);
8610
    rb_define_method(rb_cIO, "nread", rb_io_nread, 0); //--gc
8596 8611
    rb_define_alias(rb_cIO, "to_i", "fileno");
8597 8612
    rb_define_method(rb_cIO, "to_io", rb_io_to_io, 0);
8598 8613