diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-16 02:26:28 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-16 02:26:28 +0000 |
commit | f2e870c9a78a8da0f4e0aa70b613f7857535ae13 (patch) | |
tree | 5176b149d7461e2213fcf98a9c5fcf9972ad42e6 /file.c | |
parent | dcd4832d6967dab51189382793cb0aadc7705915 (diff) | |
download | ruby-f2e870c9a78a8da0f4e0aa70b613f7857535ae13.tar.gz |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -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) { |