summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-15 11:53:41 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-15 11:53:41 +0000
commitd6af2a2b214203da5b4bb8ef592026db3c4c1a40 (patch)
treeb715d017ae6f8e479678fc4a7dc35ef5e79d9615 /io.c
parent12a0b0c8f48f168994245198e62d1d40cab5d594 (diff)
* io.c, internal.h (rb_io_flush_raw): new function to select calling
fsync() (on Windows). * io.c (rb_io_flush_raw): use above function. * file.c (rb_file_truncate): use above function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/io.c b/io.c
index 9e3c39ce67..e1f0942d32 100644
--- a/io.c
+++ b/io.c
@@ -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
*