mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 13:31:49 +00:00
commit
5ecbeeda7e
2 changed files with 12 additions and 2 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
debug.log("file extension")
|
||||||
|
asserts.equals(nil, file.ext("config:test"))
|
||||||
|
asserts.equals("cfg", file.ext("config:test.cfg"))
|
||||||
|
asserts.equals("gz", file.ext("config:test.cfg.gz"))
|
||||||
|
asserts.equals("config:test.cfg", file.remove_ext("config:test.cfg.gz"))
|
||||||
|
|
||||||
debug.log("check initial state")
|
debug.log("check initial state")
|
||||||
assert(file.exists("config:"))
|
assert(file.exists("config:"))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ function file.stem(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
function file.ext(path)
|
function file.ext(path)
|
||||||
return path:match("%.([^:/\\]+)$")
|
return path:match("[^:/\\.]%.([^.:/\\]+)$")
|
||||||
end
|
end
|
||||||
|
|
||||||
function file.prefix(path)
|
function file.prefix(path)
|
||||||
|
|
@ -24,7 +24,11 @@ function file.parent(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
function file.remove_ext(path)
|
function file.remove_ext(path)
|
||||||
return string.format("%s/%s", file.parent(path), file.stem(path))
|
local ext = file.ext(path)
|
||||||
|
if not ext then
|
||||||
|
return path
|
||||||
|
end
|
||||||
|
return path:sub(1, -#ext - 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
function file.path(path)
|
function file.path(path)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue