Permalink
Browse files

Fix detection of writable IO streams.

IO#write_nonblock throws EBADF on windows.
  • Loading branch information...
1 parent f87ea07 commit 6a7499f4291d9f2aa2484f74fae7633efcd0b87b @aquasync committed Nov 27, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/ole/storage/base.rb
View
@@ -58,8 +58,13 @@ def initialize arg, mode=nil, params={}
else
# works on mri 1.8 & jruby
@io.flush
- # works on mri 1.9 & rubinius
- @io.write_nonblock('') if @io.respond_to?(:write_nonblock)
+ begin
+ # works on mri 1.9 & rubinius, throws EBADF on windows
+ @io.write_nonblock('') if @io.respond_to?(:write_nonblock)
+ rescue Errno::EBADF
+ # for windows
+ @io.syswrite('');
+ end
true
end
rescue IOError

0 comments on commit 6a7499f

Please sign in to comment.