[macruby-changes] [5044] MacRuby/trunk/io.c

source_changes at macosforge.org source_changes at macosforge.org
Fri Dec 17 00:53:16 PST 2010


Revision: 5044
          http://trac.macosforge.org/projects/ruby/changeset/5044
Author:   watson1978 at gmail.com
Date:     2010-12-17 00:53:12 -0800 (Fri, 17 Dec 2010)
Log Message:
-----------
IO#close_write will throw an IOError if the stream is readable and non-duplex.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

path = "tmp"
io = File.open(path, 'w+')

assert_raise(IOError){ io.close_write }

File.unlink(path)

puts :ok
}}}

Modified Paths:
--------------
    MacRuby/trunk/io.c

Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c	2010-12-17 06:17:58 UTC (rev 5043)
+++ MacRuby/trunk/io.c	2010-12-17 08:53:12 UTC (rev 5044)
@@ -2160,6 +2160,9 @@
     if (io_s->write_fd == -1) {
         rb_raise(rb_eIOError, "closed write stream");
     }
+    if (io_s->mode & FMODE_READABLE) {
+	rb_raise(rb_eIOError, "closing non-duplex IO for writing");
+    }
     io_close(io_s, false, true);
     return Qnil;
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101217/0c3e9cc5/attachment.html>


More information about the macruby-changes mailing list