add_pathz_libdirs/1 | Adds all the subdirectories of the given directories to the library search path. |
app_name/1 | Returns the application portion of an application directory name. |
app_version/1 | Returns the version portion of an application directory name. |
complete/1 | Equivalent to complete(filename:dirname(string()), filename:basename(string())). |
complete/2 | Given the name of a directory and a prefix (of any length) of a file or files in that directory, returns the file or files that the prefix matches, if any. |
create/2 | Equivalent to create(filename(), length(), 0). |
create/3 | Creates an empty file of a given length, padded with a given value. |
dump/2 | Writes all terms to a file. |
each_line/3 | Iterates over a text file. |
exists/1 | Checks whether a file or directory exists. |
find/3 | Finds files, filters them, and executes a callback for each one. |
import/4 | Provides a very generic interface for importing fields from files. |
import_columns/4 | Imports fields from a columnar text file. |
import_fields/5 | Imports fields from a CSV-like file. |
is_binary/1 | Makes an educated guess as to whether the file is binary (as opposed to plain ASCII text). |
is_dir/1 | Checks whether a file is a directory. |
is_world_executable/1 | Checks whether a file is executable by the entire world. |
is_world_readable/1 | Checks whether a file is readable by the entire world. |
is_world_writeable/1 | Checks whether a file is writeable by the entire world. |
last_modified/1 | Returns the local date and time the file was last modified. |
size/1 | Returns the size of a file, in bytes. |
slurp/1 | Returns the entire text file as a list of strings. |
add_pathz_libdirs(LibDirs::[dirname()]) -> ok | {error, Reason}
Adds all the subdirectories of the given directories to the library
search path. This uses code:add_pathz
and is intended to
be called from a .erlang
file or other startup file.
app_name(FileName::filename()) -> string()
Returns the application portion of an application directory name.
Everything after the last hyphen is stripped.
e.g. ce_file:app_name("/usr/local/lib/erlang/lib/foo-2.3") -> "foo"
app_version(FileName::filename()) -> string()
Returns the version portion of an application directory name.
Everything before the last hyphen is stripped.
e.g. ce_file:app_name("/usr/local/lib/erlang/lib/foo-1.9") -> "1.9"
complete(PartialFileName::string()) -> {ok, filename()} | {ambiguous, [filename()]} | {error, Reason}
Equivalent to complete(filename:dirname(string()), filename:basename(string())).
complete(DirName::dirname(), PartialFileName::string()) -> {ok, filename()} | {ambiguous, [filename()]} | {error, Reason}
Given the name of a directory and a prefix (of any length) of
a file or files in that directory, returns the file or files that
the prefix matches, if any.
e.g. ce_file:complete("/usr/local/", "e") -> {ok, "/usr/local/etc"}
create(FileName::filename(), Length::length()) -> ok | {error, Reason}
Equivalent to create(filename(), length(), 0).
create(FileName::filename(), Length::length(), Pad::byte()) -> ok | {error, Reason}
Creates an empty file of a given length, padded with a given value.
dump(Filename::filename(), List::[term()]) -> {ok, [term()]} | {error, Reason}
Writes all terms to a file. Complements file:consult/1.
each_line(Fun::'fun'(), Acc::term(), FileName::filename()) -> term()
Iterates over a text file. Thanks to Klacke for the general idea.
exists(FileName::filename()) -> true | false
Checks whether a file or directory exists. Unlike previous incarnations, this literally checks whether the file exists, i.e. whether it's file information can be read.
Finds files, filters them, and executes a callback for each one. dir() is the top directory where everything starts. pred() is a fun/1 which takes a filename and returns true if it is to be listed. action() is a fun/1 to apply to each found file which matches the predicate. Both funs are passed the full file name (up to but not including the top) as parameter. Return value is a list of the return values from the action() fun. Thanks to Klacke for providing the origin of this function.
import(Fun::'fun'(), Acc::term(), FileName::filename(), FileSchema::fileschema()) -> term()
Provides a very generic interface for importing fields from files.
import_columns(Fun::'fun'(), Acc::term(), FileName::filename(), Schema::lineschema()) -> term()
Imports fields from a columnar text file. Schema is a list of {Column,Width} tuples.
import_fields(Fun::'fun'(), Acc::term(), FileName::filename(), Delim::string(), Quote::string()) -> term()
Imports fields from a CSV-like file.
is_binary(Filename::filename()) -> true | false | {error, Reason}
Makes an educated guess as to whether the file is binary (as
opposed to plain ASCII text). The heuristic used is similar to that
of grep
and Perl's -B
operator.
The first 32K of the
file is examined for odd characters such as strange control codes or
characters with the high bit set. If too many strange characters
(>30%) are found, or if any zero bytes (nulls) are encountered,
the file is considered binary.
is_dir(Filename::filename()) -> true | false
Checks whether a file is a directory. Thanks to James Hague.
is_world_executable(Filename::filename()) -> true | false
Checks whether a file is executable by the entire world.
is_world_readable(Filename::filename()) -> true | false
Checks whether a file is readable by the entire world.
is_world_writeable(Filename::filename()) -> true | false | {error, Reason}
Checks whether a file is writeable by the entire world.
last_modified(Filename::filename()) -> {date(), time()}
Returns the local date and time the file was last modified.
size(Filename::filename()) -> integer()
Returns the size of a file, in bytes.
slurp(FileName::filename()) -> [string()]
Returns the entire text file as a list of strings. This is not a particularly scaleable solution, and is not recommended on large files.
Generated by EDoc, Feb 18 2008, 06:47:47.