IOData.File (iodata v0.9.0)
Shared implementation of the IOData protocol for open files.
Backs both file-handle impls of IOData:
PID— a file opened without:raw, served by the file server.Tuple— the{:file_descriptor, _, _}handle that:file.open/2returns for:rawfiles.
Raw handles skip the file-server hop, so every read is roughly 5x cheaper, but they can only be used from the process that opened them.
Open files in :binary mode. Text-mode reads (charlists) are converted to
binaries on the way out, but binary mode avoids the intermediate list
entirely.
Every operation here is at least one round trip to the file. split/2
validates the offset against the file size (one read_file_info);
slice/2,3 is lazy — it does no I/O, so an out-of-range slice is only
reported as :insufficient_data when it is read.