@@ -1443,6 +1443,61 @@ class IO < Object
14431443 #
14441444 def puts : (*untyped objects) -> nil
14451445
1446+ # <!--
1447+ # rdoc-file=io.c
1448+ # - pread(maxlen, offset) -> string
1449+ # - pread(maxlen, offset, out_string) -> string
1450+ # -->
1451+ # Behaves like IO#readpartial, except that it:
1452+ #
1453+ # * Reads at the given `offset` (in bytes).
1454+ # * Disregards, and does not modify, the stream's position (see
1455+ # [Position](rdoc-ref:IO@Position)).
1456+ # * Bypasses any user space buffering in the stream.
1457+ #
1458+ # Because this method does not disturb the stream's state (its position, in
1459+ # particular), `pread` allows multiple threads and processes to use the same IO
1460+ # object for reading at various offsets.
1461+ #
1462+ # f = File.open('t.txt')
1463+ # f.read # => "First line\nSecond line\n\nFourth line\nFifth line\n"
1464+ # f.pos # => 52
1465+ # # Read 12 bytes at offset 0.
1466+ # f.pread(12, 0) # => "First line\n"
1467+ # # Read 9 bytes at offset 8.
1468+ # f.pread(9, 8) # => "ne\nSecon"
1469+ # f.close
1470+ #
1471+ # Not available on some platforms.
1472+ #
1473+ def pread : (int maxlen, int offset, ?string out_string) -> String
1474+
1475+ # <!--
1476+ # rdoc-file=io.c
1477+ # - pwrite(object, offset) -> integer
1478+ # -->
1479+ # Behaves like IO#write, except that it:
1480+ #
1481+ # * Writes at the given `offset` (in bytes).
1482+ # * Disregards, and does not modify, the stream's position (see
1483+ # [Position](rdoc-ref:IO@Position)).
1484+ # * Bypasses any user space buffering in the stream.
1485+ #
1486+ # Because this method does not disturb the stream's state (its position, in
1487+ # particular), `pwrite` allows multiple threads and processes to use the same IO
1488+ # object for writing at various offsets.
1489+ #
1490+ # f = File.open('t.tmp', 'w+')
1491+ # # Write 6 bytes at offset 3.
1492+ # f.pwrite('ABCDEF', 3) # => 6
1493+ # f.rewind
1494+ # f.read # => "\u0000\u0000\u0000ABCDEF"
1495+ # f.close
1496+ #
1497+ # Not available on some platforms.
1498+ #
1499+ def pwrite : (_ToS object, int offset) -> Integer
1500+
14461501 # <!--
14471502 # rdoc-file=io.c
14481503 # - read(maxlen = nil, out_string = nil) -> new_string, out_string, or nil
0 commit comments