Wsdataselect.Dataselect (wsdataselect v1.1.46)

Copy Markdown View Source

Dataselect is an interface to the dataselect binary

Summary

Functions

Computes the path of the output file inside workdir in which the trimmed data of file will be appended by the dataselect binary.

Reads all the data files described by files from the archive using the external dataselect binary, and stores the resulting trimmed miniSEED data in a temporary working directory.

Functions

create_workdir()

output_file_path(file, workdir)

@spec output_file_path(Wsdataselect.DataFile.t(), String.t()) :: String.t()

Computes the path of the output file inside workdir in which the trimmed data of file will be appended by the dataselect binary.

Only the basename of file.path is used, so a file.path containing path separators, .. segments or absolute parts cannot escape workdir (path traversal protection).

Examples

iex> output_file_path(%DataFile{path: "FR/2025/CIEL/HNZ.D/FR.CIEL.HNZ.D.2025.083"}, "/tmp/a")
"/tmp/a/FR.CIEL.HNZ.D.2025.083"

random_postfix()

read_all_files(files)

@spec read_all_files([Wsdataselect.DataFile.t()]) ::
  {:ok, String.t()} | {:error, term()}

Reads all the data files described by files from the archive using the external dataselect binary, and stores the resulting trimmed miniSEED data in a temporary working directory.

This is the public entry point of the :dataselect (legacy) mode.

Arguments

  • files — a (non-empty) list of %DataFile{} structs to read.

Returns

  • {:ok, workdir} — where workdir is the directory in which all the produced data has been stored.
  • {:error, e} — either because some requested data could not be fetched (tuple returned by do_read_all_files/1), or because an unexpected exception was raised during the read. In the latter case the exception is logged through Logger and converted into an {:error, e} return value instead of being propagated to the caller.

Note: a match file describing files is expected to have been previously prepared (via write_match_file/2).