fsync()
public
Immediately writes all buffered data in ios to disk. Returns nil
if the underlying operating system does not support fsync(2). Note that fsync differs from using IO#sync=. The latter
ensures that data is flushed from Ruby’s buffers, but doesn’t not
guarantee that the underlying operating system actually writes it to disk.
Show source
/*
* call-seq:
* ios.fsync => 0 or nil
*
* Immediately writes all buffered data in <em>ios</em> to disk.
* Returns <code>nil</code> if the underlying operating system does not
* support <em>fsync(2)</em>. Note that <code>fsync</code> differs from
* using <code>IO#sync=</code>. The latter ensures that data is flushed
* from Ruby's buffers, but doesn't not guarantee that the underlying
* operating system actually writes it to disk.
*/
static VALUE
rb_io_fsync(io)
VALUE io;
{
#ifdef HAVE_FSYNC
rb_io_t *fptr;
FILE *f;
GetOpenFile(io, fptr);
f = GetWriteFile(fptr);
io_fflush(f, fptr);
if (fsync(fileno(f)) < 0)
rb_sys_fail(fptr->path);
return INT2FIX(0);
#else
rb_notimplement();
return Qnil; /* not reached */
#endif
}