bliss

KISS in Lua
git clone git://bvnf.space/bliss.git
Log | Files | Refs | README | LICENSE

commit 42c5f66fbd262e21771cbc05a55ed3ec2aeef205
parent 4c4a6f5995acdbd2d96bbdc9b47a67b80c8b26fe
Author: phoebos <ben@bvnf.space>
Date:   Mon,  3 Jul 2023 22:48:16 +0100

utils.mkdirp: speedup by checking if path exists first

Diffstat:
Mbliss/utils.lua | 9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)

diff --git a/bliss/utils.lua b/bliss/utils.lua @@ -130,6 +130,14 @@ end function mkdirp(...) for i = 1, select("#", ...) do local path = select(i, ...) + local sb = sys_stat.stat(path) + if sb then + if sys_stat.S_ISDIR(sb.st_mode) == 0 then + die("'" .. path .. "' already exists and is not a directory") + end + goto continue + end + assert(string.sub(path, 1, 1) == "/") local t = split(path, "/") local p = "" @@ -143,6 +151,7 @@ function mkdirp(...) end end end + ::continue:: end function mkcd(...)