mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +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")
|
||||
assert(file.exists("config:"))
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ function file.stem(path)
|
|||
end
|
||||
|
||||
function file.ext(path)
|
||||
return path:match("%.([^:/\\]+)$")
|
||||
return path:match("[^:/\\.]%.([^.:/\\]+)$")
|
||||
end
|
||||
|
||||
function file.prefix(path)
|
||||
|
|
@ -24,7 +24,11 @@ function file.parent(path)
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
function file.path(path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue