string.parent_directory

Returns a copy of a filesystem path without its final component.

Usage

string.parent_directory(path)

Arguments

Name Type Description
path string A filesystem path.

Returns

Name Type Description
directory string Filesystem path of the parent directory.

Examples

local path = "assets/sprites/evil_bat.png";
print(path:parent_directory(path)); -- Prints "assets/sprites"
local path = "assets";
print(path:parent_directory(path)); -- Prints ""
local path = "";
print(path:parent_directory(path)); -- Prints "nil"

This site uses Just the Docs, a documentation theme for Jekyll.