Skip to main content

Module nul_tail

Module nul_tail 

Source
Expand description

A text file that ends in a run of NUL bytes ends where the run starts. Loggers that preallocate a file at a fixed size and never write past their last line leave the rest as NULs, which a CSV reader would take as one last row of junk text.

Finding the run costs one byte read for a file that has none: its last byte. Only a file whose last byte is NUL is mapped and scanned back to its last other byte.

Functionsยง

holds_nothing
Whether the file at path holds no text: empty, or nothing but NULs. One byte read for a file that ends in anything else.
text_buffer
The text of the file at path as a buffer Polars scans in place, when the file ends in NULs; None when it does not, and the file is scanned by its path.
text_end
Where the text of bytes ends: before its trailing run of NULs, or None when it has none, or when the NULs are part of the text (UTF-16 or UTF-32, by its byte-order mark, or by a NUL beside the last character).
text_len
How many bytes of the file at file are text, when it ends in NULs.
trim
bytes, decompressed into memory, without a trailing run of NULs.