File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
src/main/ruby/truffleruby/core Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -444,8 +444,26 @@ def self.read_to_buffer_native(io, length)
444
444
end
445
445
end
446
446
447
- def self . read_to_buffer_polyglot ( io , count )
448
- raise RuntimeError , 'Not supported yet.'
447
+ def self . read_to_buffer_polyglot ( io , length , &block )
448
+ fd = io . fileno
449
+ if fd == 0
450
+ buffer = Primitive . io_thread_buffer_allocate ( length )
451
+ begin
452
+ read = Primitive . io_read_polyglot length
453
+ if read
454
+ bytes_read = read . bytesize
455
+ buffer . write_string_length ( read , bytes_read )
456
+ yield buffer , bytes_read
457
+ [ bytes_read , 0 ]
458
+ else
459
+ [ 0 , 0 ]
460
+ end
461
+ ensure
462
+ Primitive . io_thread_buffer_free ( buffer )
463
+ end
464
+ else
465
+ read_to_buffer_native ( io , length , &block )
466
+ end
449
467
end
450
468
451
469
def self . read_string_polyglot ( io , length )
You can’t perform that action at this time.
0 commit comments