Path
Description:
Helper class for file path operations.
getScriptPath
Type: Function.
Description:
Gets script running path from a module name.
Signature:
getScriptPath: function(self: Path, moduleName: string): string
Usage:
-- in the script entry file named 'init'
local scriptPath = Path:getScriptPath(...)
-- set up the project search paths
Content:insertSearchPath(1, scriptPath)
Parameters:
Parameter | Type | Description |
---|---|---|
moduleName | string | The input module name. |
Returns:
Return Type | Description |
---|---|
string | The module path for script searching. |
getExt
Type: Function.
Description:
Input: /a/b/c.TXT output: txt
Signature:
getExt: function(self: Path, path: string): string
Parameters:
Parameter | Type | Description |
---|---|---|
path | string | The input file path. |
Returns:
Return Type | Description |
---|---|
string | The input file's extension. |
getPath
Type: Function.
Description:
Input: /a/b/c.TXT output: /a/b
Signature:
getPath: function(self: Path, path: string): string
Parameters:
Parameter | Type | Description |
---|---|---|
path | string | The input file path. |
Returns:
Return Type | Description |
---|---|
string | The input file's parent path. |
getName
Type: Function.
Description:
Input: /a/b/c.TXT output: c
Signature:
getName: function(self: Path, path: string): string
Parameters:
Parameter | Type | Description |
---|---|---|
path | string | The input file path. |
Returns:
Return Type | Description |
---|---|
string | The input file's name without extension. |
getFilename
Type: Function.
Description:
Input: /a/b/c.TXT output: c.TXT
Signature:
getFilename: function(self: Path, path: string): string
Parameters:
Parameter | Type | Description |
---|---|---|
path | string | The input file path. |
Returns:
Return Type | Description |
---|---|
string | The input file's name. |
getRelative
Type: Function.
Description:
Input: /a/b/c.TXT, base: /a output: b/c.TXT
Signature:
getRelative: function(self: Path, path: string, base: string): string
Parameters:
Parameter | Type | Description |
---|---|---|
path | string | The input file path. |
base | string | The target file path. |
Returns:
Return Type | Description |
---|---|
string | The relative from input file to target file. |
replaceExt
Type: Function.
Description:
Input: /a/b/c.TXT, lua output: /a/b/c.lua
Signature:
replaceExt: function(self: Path, path: string, newExt: string): string
Parameters:
Parameter | Type | Description |
---|---|---|
path | string | The input file path. |
newExt | string | The new file extention to add to file path. |
Returns:
Return Type | Description |
---|---|
string | The new file path. |
replaceFilename
Type: Function.
Description:
Input: /a/b/c.TXT, d output: /a/b/d.TXT
Signature:
replaceFilename: function(self: Path, path: string, newFile: string): string
Parameters:
Parameter | Type | Description |
---|---|---|
path | string | The input file path. |
newFile | string | The new filename to replace. |
Returns:
Return Type | Description |
---|---|
string | The new file path. |
__call
Type: Metamethod.
Description:
input: a, b, c.TXT output: a/b/c.TXT
Signature:
metamethod __call: function(self: Path, ...: string): string
Parameters:
Parameter | Type | Description |
---|---|---|
... | string | The segments to be joined as a new file path. |
Returns:
Return Type | Description |
---|---|
string | The new file path. |