mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
dcd4832d69
commit
f2e870c9a7
3 changed files with 12 additions and 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
|
||||
|
|
8
file.c
8
file.c
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue