This module provides functions
for analyzing and manipulating filenames. These functions are
designed so that the Erlang code can work on many different
platforms with different filename formats. With filename
is meant all strings that can be used to denote a file. The filename
can be a short relative name like foo.erl, a long absolute
name including a drive designator, a directory name like
D:\usr/local\bin\erl/lib\tools\foo.erl, or any variations
in between.
In Windows, all functions return filenames with forward slashes
only, even if the arguments contain backslashes. To normalize a
filename by removing redundant directory separators, use
join/1.
The module supports
raw
filenames in the way that if a binary is
present, or the filename cannot be interpreted according to the return
value of
file:native_name_encoding/0, a raw filename is also
returned. For example, join/1 provided with a path component
that is a binary (and cannot be interpreted under the current
native filename encoding) results in a raw filename that is returned
(the join operation is performed of course). For more information
about raw filenames, see the
file module.
Note
Functionality in this module generally assumes valid input and
does not necessarily fail on input that does not use a valid
encoding, but may instead very likely produce invalid output.
File operations used to accept filenames containing
null characters (integer value zero). This caused
the name to be truncated and in some cases arguments
to primitive operations to be mixed up. Filenames
containing null characters inside the filename
are now rejected and will cause primitive
file operations to fail.
Warning
Currently null characters at the end of the filename
will be accepted by primitive file operations. Such
filenames are however still documented as invalid. The
implementation will also change in the future and
reject such filenames.