mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 15:33:00 +00:00
Create file_path.lua
This commit is contained in:
parent
449f12d5d7
commit
8f54522e20
1 changed files with 17 additions and 0 deletions
17
worldeditadditions_core/utils/format/file_path.lua
Normal file
17
worldeditadditions_core/utils/format/file_path.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
-- @module worldeditadditions_core
|
||||
local wea_c = worldeditadditions_core
|
||||
|
||||
--- Joins the given path segments into a single path with dirsep.
|
||||
-- @param ... string The path fragments to process and join.
|
||||
-- @return string The joined path.
|
||||
-- @example Basic usage
|
||||
-- local path = file_path("C:\\Users", "me", "/Documents/code.lua")
|
||||
local file_path = function( ... )
|
||||
local path = { ... }
|
||||
for i, v in ipairs(path) do path[i] = tostring(v) end
|
||||
return ({table.concat(path, wea_c.dirsep)
|
||||
:gsub("[/\\]+", wea_c.dirsep)})[1]
|
||||
end
|
||||
|
||||
return file_path
|
Loading…
Reference in a new issue