ExMagic v0.0.3 ExMagic View Source

Binding to libmagic to gather information about a file.

Link to this section Summary

Functions

Retrieves magic information from the given buffer.

Retrieves magic information from the given buffer. Fails on an error.

Retrieves magic information from the given file.

Retrieves magic information from the given file. Fails on an error.

Returns the version of libmagic in use.

Link to this section Functions

Link to this function

from_buffer(buf)

View Source
from_buffer(binary()) :: {:ok, binary()} | {:error, atom()}
from_buffer(List.t()) :: {:ok, binary()} | {:error, atom()}

Retrieves magic information from the given buffer.

Examples

iex> ExMagic.from_buffer("foo")
{:ok, "text/plain"}
Link to this function

from_buffer!(buf)

View Source
from_buffer!(binary()) :: binary()
from_buffer!(List.t()) :: binary()

Retrieves magic information from the given buffer. Fails on an error.

Examples

iex> ExMagic.from_buffer!("foo")
"text/plain"
Link to this function

from_file(path)

View Source
from_file(String.t()) :: {:ok, binary()} | {:error, atom()}

Retrieves magic information from the given file.

Link to this function

from_file!(path)

View Source
from_file!(String.t()) :: binary()

Retrieves magic information from the given file. Fails on an error.

Returns the version of libmagic in use.

Examples

iex> ExMagic.version()
529