Util (fnord v0.7.24)
View SourceSummary
Functions
Filters an enumerable asynchronously using the provided function. The
function should return true
for items to keep and false
for items to
discard. The result is a stream of items that passed the filter.
Convenience wrapper for Task.async_stream/3
with the default options for
concurrency and timeout set to Application.get_env(:fnord, :workers)
and
:infinity
, respectively.
Expands a given path to its absolute form, expanding .
and ..
. If a root
directory is provided, it will expand the path relative to that root. If no
root is provided, it will expand the path relative to the current working
directory. The root directory is expanded first, if provided (see
Path.expand/2
).
Shortcut for find_file_within_root(path, <cwd>)
. Returns {:error, :enoent}
if the current working directory cannot be determined.
Finds a file within the specified root directory. It resolves symlinks for
both the file path and the root directory. If the resolved file path is
within the root directory, it returns {:ok, resolved_path}
, otherwise
{:error, :enoent}
.
Returns true
if the given path is within the specified root directory,
false
otherwise. Expands both the path and the root to their absolute
forms, resolving symlinks, before performing the check.
Resolves a symlink to its final target. If the path is relative, it will
first be expanded relative to the given root. If root is not provided, it
will expand relative to the current working directory. If a circular symlink
is detected, it returns {:error, :circular_symlink}
. Otherwise, it returns
the absolute, resolved path or the error tuple originating from
File.lstat/1
.
Converts all string keys in a map to atoms, recursively.
Types
Functions
Filters an enumerable asynchronously using the provided function. The
function should return true
for items to keep and false
for items to
discard. The result is a stream of items that passed the filter.
@spec async_stream(Enumerable.t(), async_cb(), Keyword.t()) :: Enumerable.t()
Convenience wrapper for Task.async_stream/3
with the default options for
concurrency and timeout set to Application.get_env(:fnord, :workers)
and
:infinity
, respectively.
Expands a given path to its absolute form, expanding .
and ..
. If a root
directory is provided, it will expand the path relative to that root. If no
root is provided, it will expand the path relative to the current working
directory. The root directory is expanded first, if provided (see
Path.expand/2
).
Shortcut for find_file_within_root(path, <cwd>)
. Returns {:error, :enoent}
if the current working directory cannot be determined.
Finds a file within the specified root directory. It resolves symlinks for
both the file path and the root directory. If the resolved file path is
within the root directory, it returns {:ok, resolved_path}
, otherwise
{:error, :enoent}
.
Returns true
if the given path is within the specified root directory,
false
otherwise. Expands both the path and the root to their absolute
forms, resolving symlinks, before performing the check.
@spec resolve_symlink(binary(), binary() | nil) :: {:ok, binary()} | {:error, :circular_symlink} | {:error, File.posix()}
Resolves a symlink to its final target. If the path is relative, it will
first be expanded relative to the given root. If root is not provided, it
will expand relative to the current working directory. If a circular symlink
is detected, it returns {:error, :circular_symlink}
. Otherwise, it returns
the absolute, resolved path or the error tuple originating from
File.lstat/1
.
Converts all string keys in a map to atoms, recursively.