Documentation ¶
Overview ¶
Package filepath implements golang filepath functionality for lua.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Basename ¶
Basename lua filepath.basename(path) returns the last element of path
Example ¶
filepath.basename(string)
state := lua.NewState() Preload(state) source := ` local filepath = require("filepath") local result = filepath.basename("/var/tmp/file.name") print(result) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: file.name
func Dir ¶
Dir lua filepath.dir(path) returns all but the last element of path, typically the path's directory
Example ¶
filepath.basename(string)
state := lua.NewState() Preload(state) source := ` local filepath = require("filepath") local result = filepath.dir("/var/tmp/file.name") print(result) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: /var/tmp
func Ext ¶
Ext lua filepath.ext(path) returns the file name extension used by path.
Example ¶
filepath.ext(string)
state := lua.NewState() Preload(state) source := ` local filepath = require("filepath") local result = filepath.ext("/var/tmp/file.name") print(result) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: .name
func Glob ¶
filepath.glob(pattern) returns the names of all files matching pattern or nil if there is no matching file.
Example ¶
filepath.glob(string)
state := lua.NewState() Preload(state) inspect.Preload(state) source := ` local filepath = require("filepath") local inspect = require("inspect") local result = filepath.glob("./*/*.lua") print(inspect(result, {newline="", indent=""})) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: { "test/test_api.lua" }
func Join ¶
Join lua fileapth.join(path, ...) joins any number of path elements into a single path, adding a Separator if necessary.
Example ¶
filepath.basename(string)
state := lua.NewState() Preload(state) source := ` local filepath = require("filepath") local result = filepath.join("var", "tmp", "file.name") print(result) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: var/tmp/file.name
func ListSeparator ¶
ListSeparator lua filepath.list_separator() OS-specific path list separator
Types ¶
This section is empty.