v2_5_5 - Show latest stable - 0 notes - Class: IO
pwrite(p1, p2) public

Writes the given string to ios at offset using pwrite() system call. This is advantageous to combining IO#seek and IO#write in that it is atomic, allowing multiple threads/process to share the same IO object for reading the file at various locations. This bypasses any userspace buffering of the IO layer. Returns the number of bytes written. Raises SystemCallError on error and NotImplementedError if platform does not implement the system call.

File.open("out", "w") do |f|
  f.pwrite("ABCDEF", 3)   #=> 6

File.read("out")          #=> "\u0000\u0000\u0000ABCDEF"
Show source
Register or log in to add new notes.