Module filename
An implementation of a subset of the Erlang/OTP filename interface.
Description
This module implements a strict subset of the Erlang/OTP filename interface.
Function Index
| basename/1 | Return the last component of a file name, ignoring a single trailing slash (further ones make the last component empty). |
| basename/2 | Like basename/1, but also removes the extension Ext when the
base name ends with it. |
| dirname/1 | Return the directory part of a file name, "." if there is none. |
| extension/1 | Return the file extension of the last path component, "" if the last component has no dot. |
| join/1 | Join a list of path components. |
| join/2 | Join two path components, equivalent to join([Name1, Name2]). |
| rootname/1 | Remove the extension of the last path component, if any. |
| rootname/2 | Remove Ext from Name when it is its extension. |
| split/1 | Split a path into its components. |
Function Details
basename/1
basename(Name::string()) -> string()
Name: a file name
returns: the last component of Name
Return the last component of a file name, ignoring a single trailing slash (further ones make the last component empty).
basename/2
basename(Name::string(), Ext::string()) -> string()
Name: a file nameExt: an extension
returns: the last component of Name, with Ext stripped if it matches
Like basename/1, but also removes the extension Ext when the
base name ends with it.
dirname/1
dirname(Name::string()) -> string()
Name: a file name
returns: the directory part of Name
Return the directory part of a file name, “.” if there is none.
extension/1
extension(Name::string()) -> string()
Name: a file name
returns: the extension of Name, including the dot, or “” if there is none
Return the file extension of the last path component, “” if the last component has no dot.
join/1
join(Components::[string()]) -> string()
Components: list of path components to join
returns: the path formed by joining the components with “/”
Join a list of path components.
If a component is absolute (starts with “/”), all preceding components are discarded. Redundant directory separators and “.” components followed by a separator are removed from the result.
join/2
join(Name1::string(), Name2::string()) -> string()
Name1: first path componentName2: second path component
returns: the path formed by joining Name1 and Name2
Join two path components, equivalent to join([Name1, Name2]).
rootname/1
rootname(Name::string()) -> string()
Name: a file name
returns: Name with its extension removed
Remove the extension of the last path component, if any.
rootname/2
rootname(Name::string(), Ext::string()) -> string()
Name: a file nameExt: an extension
returns: Name with Ext removed if Name ends with Ext
Remove Ext from Name when it is its extension.
split/1
split(Name::string()) -> [string()]
Name: a path to split into its components
returns: list of path components
Split a path into its components.
If the path is absolute, the first component is “/”. Redundant directory separators are treated as a single separator. Trailing separators are ignored.