ModPath
See the code atutils/path.gdDescription
Inherits Object
Utilities to help with mod file system paths.
Properties
ExtensionRegEx
static var ExtensionRegEx: RegEx = RegEx.create_from_string("\\.(?<ext>((?<sub_ext>[^.\\/]+)\\.)?(?<main_ext>[^\\/.]+))$")
A RegEx that captures three groups from a file path.
ext- the full extensionsub_ext- the sub extension, if it existsmain_ext- the main extension
Note: While this is a variable, it is NOT meant to be mutated.
Ex.
my_mod.mod.json
extismod.jsonsub_extismodmain_extisjson
| Type | RegEx |
|---|---|
| Default | \.(?<ext>((?<sub_ext>[^.\/]+)\.)?(?<main_ext>[^\/.]+))$ |
Methods
get_extension
static func get_extension(path: String) -> String
Returns the extended extension of the given path.
Note: This is a static method, intended to be called directly on the ModPath class.
Examples
assert(ModPath.get_extension("my_mod.mod.json") == "mod.json")
assert(ModPath.get_extension("my_mod.tres") == "tres")
Parameters
| Name | Type | Description |
|---|---|---|
path | String | The file path from which to get the extension. |
Returns
| Type | String |
|---|---|
| Description | The file path's extension. |
is_mod_path
static func is_mod_path(path: String) -> bool
Checks if the provided path is a mod file path.
Returns true if the given path is in the format *.mod.tres, *.mod.res, or *.mod.json.
Note: This is a static method, intended to be called directly on the ModPath class.
Parameters
| Name | Type | Description |
|---|---|---|
path | String | The file path to check. |
Returns
| Type | bool |
|---|---|
| Description | Returns true if the given path is in the format *.mod.tres, *.mod.res, or *.mod.json. |
to_import_path
static func to_import_path(path: String) -> String
Creates a new path with extension .import.tres.
Note: This is a static method, intended to be called directly on the ModPath class.
Parameters
| Name | Type | Description |
|---|---|---|
path | String | The file path to check. |
Returns
| Type | String |
|---|---|
| Description | The modified path. |