Create file_path.lua

This commit is contained in:
VorTechnix 2024-10-23 15:18:35 -07:00
parent 449f12d5d7
commit 8f54522e20
No known key found for this signature in database
GPG key ID: 091E91A69545D5BA

View 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