View Source Moar.File (Moar v1.62.0)
File-related functions.
Summary
Functions
Generate a sha256 checksum of a file's contents
Returns a randomly-named path in the system temp directory. Does not actually create the file at the path.
Delegates to File.stream!/2
in a way that's compatible with older Elixir versions.
Writes contents
to a new temp file with extension file_extension
, and returns the path to the file.
Functions
Generate a sha256 checksum of a file's contents
Returns a randomly-named path in the system temp directory. Does not actually create the file at the path.
For example, Moar.File.new_tempfile_path(".txt")
would return something like
"/var/folders/3r/n09zyyy16yddj9m2d1ppzvt40000gn/T/XY7V5E26DV.txt"
.
iex> Moar.File.new_tempfile_path(".txt") |> File.exists?()
false
@spec stream!(Path.t(), pos_integer()) :: File.Stream.t()
Delegates to File.stream!/2
in a way that's compatible with older Elixir versions.
Writes contents
to a new temp file with extension file_extension
, and returns the path to the file.
For example, Moar.File.write_tempfile("hello", ".txt")
would create a file in a path something like
/var/folders/3r/n09zyyy16yddj9m2d1ppzvt40000gn/T/RHUEJCCH22.txt
with the contents hello
.
iex> Moar.File.write_tempfile("hello", ".txt") |> File.read!()
"hello"