Module ec_file

Helper functions for working with files.

Copyright © (C) 2011, Erlware LLC

Description

Helper functions for working with files.

Data Types

file_info()

file_info() = mode | time | owner | group

option()

option() = recursive | {file_info, [file_info()]}

Function Index

copy/2copy a file including timestamps,ownership and mode etc.
copy/3copy an entire directory to another location.
copy_file_info/3
exists/1
find/2Finds files and directories that match the regexp supplied in the TargetPattern regexp.
insecure_mkdtemp/0make a unique temporary directory.
is_dir/1
is_symlink/1indicates witha boolean if the path supplied refers to symlink.
md5sum/1return an md5 checksum string or a binary.
mkdir_p/1Makes a directory including parent dirs if they are missing.
mkdir_path/1Makes a directory including parent dirs if they are missing.
read/1read a file from the file system.
real_dir_path/1gets the real path of a directory.
remove/1delete a file.
remove/2delete a file.
sha1sum/1return an sha1sum checksum string or a binary.
type/1returns the type of the file.
write/2write a file to the file system.
write_term/2write a term out to a file so that it can be consulted later.

Function Details

copy/2

copy(From::file:filename(), To::file:filename()) -> ok | {error, Reason::term()}

copy a file including timestamps,ownership and mode etc.

copy/3

copy(From::file:name(), To::file:name(), Options::[option()]) -> ok | {error, Reason::term()}

copy an entire directory to another location.

copy_file_info/3

copy_file_info(To, From, FileInfoToKeep) -> any()

exists/1

exists(Filename::file:filename()) -> boolean()

find/2

find(FromDir::file:name(), TargetPattern::string()) -> [file:name()]

Finds files and directories that match the regexp supplied in the TargetPattern regexp.

insecure_mkdtemp/0

insecure_mkdtemp() -> TmpDirPath::file:name()

make a unique temporary directory. Similar function to BSD stdlib function of the same name.

is_dir/1

is_dir(Path) -> any()

is_symlink/1

is_symlink(Path::file:name()) -> boolean()

indicates witha boolean if the path supplied refers to symlink.

md5sum/1

md5sum(Value::string() | binary()) -> string()

return an md5 checksum string or a binary. Same as unix utility of same name.

mkdir_p/1

mkdir_p(Path::file:name()) -> ok | {error, Reason::term()}

Makes a directory including parent dirs if they are missing.

mkdir_path/1

mkdir_path(Path::file:name()) -> ok | {error, Reason::term()}

Makes a directory including parent dirs if they are missing.

read/1

read(FilePath::file:filename()) -> {ok, binary()} | {error, Reason::term()}

read a file from the file system. Provide UEX exeption on failure.

real_dir_path/1

real_dir_path(Path::file:name()) -> file:name()

gets the real path of a directory. This is mostly useful for resolving symlinks. Be aware that this temporarily changes the current working directory to figure out what the actual path is. That means that it can be quite slow.

remove/1

remove(Path::file:name()) -> ok | {error, Reason::term()}

delete a file.

remove/2

remove(Path::file:name(), Options::[option()]) -> ok | {error, Reason::term()}

delete a file. Use the recursive option for directories.

  Example: remove("./tmp_dir", [recursive]).
  

sha1sum/1

sha1sum(Value::string() | binary()) -> string()

return an sha1sum checksum string or a binary. Same as unix utility of same name.

type/1

type(Path::file:name()) -> file | symlink | directory | undefined

returns the type of the file.

write/2

write(FileName::file:filename(), Contents::string()) -> ok | {error, Reason::term()}

write a file to the file system. Provide UEX exeption on failure.

write_term/2

write_term(FileName::file:filename(), Term::term()) -> ok | {error, Reason::term()}

write a term out to a file so that it can be consulted later.


Generated by EDoc, May 1 2024, 06:09:58.