Saucexages v0.2.0 Saucexages.IO.SauceFile View Source

Functions for handling SAUCE files in the file system.

Any devices passed are assumed to be file descriptors that are opened using :read and :binary at the minimum. SAUCE does not use UTF-8 files, so do not pass such devices or you risk incorrect behavior.

Link to this section Summary

Functions

Returns the byte size of the contents in a file, before any potential SAUCE block

Reads a SAUCE file descriptor and returns the byte size of the SAUCE file from the file descriptor

Checks if the file descriptor is for a SAUCE

Splits a SAUCE file into parts by contents, and optionally SAUCE, and finally comments. Each part is a tuple of position and length

Link to this section Types

Link to this section Functions

Link to this function contents_size(fd) View Source
contents_size(File.io_device()) :: {:ok, non_neg_integer()} | {:error, term()}

Returns the byte size of the contents in a file, before any potential SAUCE block.

Contents is strictly defined as all data before a properly written SAUCE record and optionally a comments block. If there is no SAUCE data, the contents size is the actual size of the file.

Link to this function read_byte_size(fd) View Source
read_byte_size(File.io_device()) :: {:ok, non_neg_integer()} | {:error, term()}

Reads a SAUCE file descriptor and returns the byte size of the SAUCE file from the file descriptor.

Checks if the file descriptor is for a SAUCE.

Link to this function split_parts(fd) View Source
split_parts(File.io_device()) ::
  {:ok, {part()}} | {:ok, {part(), part()}} | {:ok, {part(), part(), part()}}

Splits a SAUCE file into parts by contents, and optionally SAUCE, and finally comments. Each part is a tuple of position and length.

Parts will be returned in the following possible forms:

  • {contents, sauce, comments} - SAUCE with comments
  • {contents, sauce} - SAUCE with no comments
  • {contents} - No SAUCE

Each part has the form - {position, length} where position is absolute within the file.