diff options
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 42 |
1 files changed, 24 insertions, 18 deletions
@@ -1464,24 +1464,8 @@ nogvl_fsync(void *ptr) } #endif -/* - * call-seq: - * ios.flush -> ios - * - * Flushes any buffered data within <em>ios</em> to the underlying - * operating system (note that this is Ruby internal buffering only; - * the OS may buffer the data as well). - * - * $stdout.print "no newline" - * $stdout.flush - * - * <em>produces:</em> - * - * no newline - */ - VALUE -rb_io_flush(VALUE io) +rb_io_flush_raw(VALUE io, int sync) { rb_io_t *fptr; @@ -1496,7 +1480,7 @@ rb_io_flush(VALUE io) if (io_fflush(fptr) < 0) rb_sys_fail(0); #ifdef _WIN32 - if (GetFileType((HANDLE)rb_w32_get_osfhandle(fptr->fd)) == FILE_TYPE_DISK) { + if (sync && GetFileType((HANDLE)rb_w32_get_osfhandle(fptr->fd)) == FILE_TYPE_DISK) { rb_thread_io_blocking_region(nogvl_fsync, fptr, fptr->fd); } #endif @@ -1510,6 +1494,28 @@ rb_io_flush(VALUE io) /* * call-seq: + * ios.flush -> ios + * + * Flushes any buffered data within <em>ios</em> to the underlying + * operating system (note that this is Ruby internal buffering only; + * the OS may buffer the data as well). + * + * $stdout.print "no newline" + * $stdout.flush + * + * <em>produces:</em> + * + * no newline + */ + +VALUE +rb_io_flush(VALUE io) +{ + return rb_io_flush_raw(io, 1); +} + +/* + * call-seq: * ios.pos -> integer * ios.tell -> integer * |