Module rebar_file_utils

Function Index

absolute_path/1make a path absolute.
canonical_path/1
consult_any_config/2Reads a config file via consult_env_config/2 if the file name has the suffix .src, and with consult_config/2 otherwise.
consult_config/2Parse a sys.config file and return the configuration terms for all its potentially nested configs.
consult_config_terms/2From a parsed sys.config file, expand all the terms to include its potential nested configs.
consult_env_config/2Like consult_config/2 but expanding environment variables as for a sys.config.src file.
cp_r/2
cp_r/3Copies files and directories.
delete_each/1
ensure_dir/1
format_error/1
mv/2
normalize_relative_path/1normalizes relative paths so that ./a/b/c/ => a/b/c.
normalized_path/1normalizing a path removes all of the .. and the . segments it may contain.
path_from_ancestor/2
reset_dir/1
resolve_link/1returns canonical target of path if path is a link, otherwise returns path.
rm_rf/1Remove files and directories.
split_dirname/1splits a path into dirname and basename.
symlink_or_copy/2
system_tmpdir/0
system_tmpdir/1
touch/1
try_consult/1
write_file_if_contents_differ/2backwards compat layer to pre-utf8 support.
write_file_if_contents_differ/3let the user pick the encoding required; there are no good heuristics for data encoding.

Function Details

absolute_path/1

absolute_path(Path::file:filename()) -> file:filename()

make a path absolute

canonical_path/1

canonical_path(Dir::string()) -> string()

consult_any_config/2

consult_any_config(State::rebar_state:t(), Filename::file:filename()) -> [[tuple()]]

Reads a config file via consult_env_config/2 if the file name has the suffix .src, and with consult_config/2 otherwise

consult_config/2

consult_config(State::rebar_state:t(), Filename::string()) -> [[tuple()]]

Parse a sys.config file and return the configuration terms for all its potentially nested configs.

consult_config_terms/2

consult_config_terms(State::rebar_state:t(), Config::[tuple()]) -> [[tuple()]]

From a parsed sys.config file, expand all the terms to include its potential nested configs. It is also possible that no sub-terms (i.e. the config file does not refer to "some/other/file.config") that the input term is returned as-is.

This function is added mostly to help with variable substitution and evaluation of 'sys.config.src' files, giving a way to handle expansion that is separate from regular config handling.

consult_env_config/2

consult_env_config(State::rebar_state:t(), Filename::file:filename()) -> [[tuple()]]

Like consult_config/2 but expanding environment variables as for a sys.config.src file

cp_r/2

cp_r(Sources::[string()], Dest::file:filename()) -> ok

cp_r/3

cp_r(Sources::[string()], Dest::file:filename(), Options::proplists:proplist()) -> ok

Copies files and directories. Options is a proplist with the options to be added to the copy command. It options are: - [{dereference, true|false}]: When true, if the file is a symbolic link it dereferences and copies the original content in Dest

delete_each/1

delete_each(Rest) -> any()

ensure_dir/1

ensure_dir(Path::file:name_all()) -> ok | {error, file:posix()}

format_error/1

format_error(X1) -> any()

mv/2

mv(Source::string(), Dest::file:filename()) -> ok

normalize_relative_path/1

normalize_relative_path(Path::string()) -> file:filename()

normalizes relative paths so that ./a/b/c/ => a/b/c

normalized_path/1

normalized_path(Path::file:filename()) -> file:filename()

normalizing a path removes all of the .. and the . segments it may contain.

path_from_ancestor/2

path_from_ancestor(Target::string(), To::string()) -> {ok, string()} | {error, badparent}

reset_dir/1

reset_dir(Path) -> ok | {error, Reason}

resolve_link/1

resolve_link(Path::string()) -> string()

returns canonical target of path if path is a link, otherwise returns path

rm_rf/1

rm_rf(Target::string()) -> ok

Remove files and directories. Target is a single filename, directoryname or wildcard expression.

split_dirname/1

split_dirname(Path::string()) -> {string(), string()}

splits a path into dirname and basename

symlink_or_copy/2

symlink_or_copy(Source, Target) -> any()

system_tmpdir/0

system_tmpdir() -> file:filename()

system_tmpdir/1

system_tmpdir(PathComponents) -> file:filename()

touch/1

touch(Path) -> ok | {error, Reason}

try_consult/1

try_consult(File) -> any()

write_file_if_contents_differ/2

write_file_if_contents_differ(Filename, Bytes) -> any()

backwards compat layer to pre-utf8 support

write_file_if_contents_differ/3

write_file_if_contents_differ(Filename, Bytes, X3) -> any()

let the user pick the encoding required; there are no good heuristics for data encoding


Generated by EDoc