Module luarocks.dir

Generic utilities for handling pathnames.

Functions

base_name (pathname) Strip the path off a path+filename.
dir_name (pathname) Strip the name off a path+filename.
path (...) Describe a path in a cross-platform way.
split_url (url) Split protocol and path from an URL or local pathname.


Functions

base_name (pathname)
Strip the path off a path+filename.

Parameters

  • pathname: string: A path+name, such as "/a/b/c" or "\a\b\c".

Return value:

string: The filename without its path, such as "c".
dir_name (pathname)
Strip the name off a path+filename.

Parameters

  • pathname: string: A path+name, such as "/a/b/c".

Return value:

string: The filename without its path, such as "/a/b/". For entries such as "/a/b/", "/a/" is returned. If there are no directory separators in input, "" is returned.
path (...)
Describe a path in a cross-platform way. Use this function to avoid platform-specific directory separators in other modules. If the first item contains a protocol descriptor (e.g. "http:"), paths are always constituted with forward slashes.

Parameters

  • ...: strings representing directories

Return value:

string: a string with a platform-specific representation of the path.
split_url (url)
Split protocol and path from an URL or local pathname. URLs should be in the "protocol://path" format. For local pathnames, "file" is returned as the protocol.

Parameters

  • url: string: an URL or a local pathname.

Return value:

string, string: the protocol, and the pathname without the protocol.

Valid XHTML 1.0!