diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | file.c | 8 | ||||
-rw-r--r-- | test/ruby/test_file.rb | 1 |
3 files changed, 12 insertions, 6 deletions
@@ -1,3 +1,12 @@ +Fri Aug 16 11:23:35 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * file.c (rb_file_size, rb_file_flock): improve parformance of Winodws. + + * file.c (rb_file_truncate): removed unnecessary #ifdef. + + * test/test_file.rb (TestFile#test_truncate_size): added an assertion + for File#size. + Fri Aug 16 10:07:59 2013 Tanaka Akira <akr@fsij.org> * bignum.c (bigdivrem_single1): Renamed from bigdivrem_single. Add @@ -2083,7 +2083,7 @@ rb_file_size(VALUE obj) GetOpenFile(obj, fptr); if (fptr->mode & FMODE_WRITABLE) { - rb_io_flush(obj); + rb_io_flush_raw(obj, 0); } if (fstat(fptr->fd, &st) == -1) { rb_sys_fail_path(fptr->pathv); @@ -4244,11 +4244,7 @@ rb_file_truncate(VALUE obj, VALUE len) if (!(fptr->mode & FMODE_WRITABLE)) { rb_raise(rb_eIOError, "not opened for writing"); } -#ifndef _WIN32 - rb_io_flush(obj); -#else rb_io_flush_raw(obj, 0); -#endif #ifdef HAVE_FTRUNCATE if (ftruncate(fptr->fd, pos) < 0) rb_sys_fail_path(fptr->pathv); @@ -4355,7 +4351,7 @@ rb_file_flock(VALUE obj, VALUE operation) op[0] = fptr->fd; if (fptr->mode & FMODE_WRITABLE) { - rb_io_flush(obj); + rb_io_flush_raw(obj, 0); } while ((int)rb_thread_io_blocking_region(rb_thread_flock, op, fptr->fd) < 0) { switch (errno) { diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb index 50f101867a..25ad11c64f 100644 --- a/test/ruby/test_file.rb +++ b/test/ruby/test_file.rb @@ -139,6 +139,7 @@ class TestFile < Test::Unit::TestCase while size = q1.pop assert_equal size, File.size(f.path) + assert_equal size, f.size q2.push true end end |