util.paths

util.paths provides some cross-platform operations on file system paths.

API

resolve_relative_path

Given a base (parent) path and a relative path, returns an absolute path.

parent_path = "/var/lib/prosody"
path = "example.com"
print(paths.resolve_relative_path(parent_path, path))
--> "/var/lib/prosody/example.com"

print(paths.resolve_relative_path(parent_path, "../foo"))
--> "/var/lib/foo"

glob_to_pattern

Turns a glob (e.g. "*.foo") into a Lua pattern for use in matching file names.

print(paths.glob_to_pattern("*.foo"))
--> "^.*%.foo$"

join

Joins a number of path components using the system path separator.

print(paths.join("path", "to", "something"))
--> "path/to/something"