utility.tmp_file_name function added

This commit is contained in:
Tangent / Rose / Nebula Rosa 2024-01-13 15:43:38 -07:00
parent a5a8e3a5f3
commit 72f059506c

View File

@ -3,7 +3,7 @@ math.randomseed(os.time())
-- TODO look for popen command and fall back to outputting to file if its unavailable -- TODO look for popen command and fall back to outputting to file if its unavailable
function os.command(command) function os.command(command)
local file = assert(io.popen(command, 'r')) local file = assert(io.popen(command, 'r'))
local output = assert(file:read('*a')) local output = assert(file:read('*all'))
file:close() file:close()
return output return output
end end
@ -32,6 +32,10 @@ utility.uuid = function()
return (("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"):gsub("[xy]", fn)) return (("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"):gsub("[xy]", fn))
end end
utility.tmp_file_name = function()
return ".tmp." .. utility.uuid()
end
utility.escape_quotes = function(input) utility.escape_quotes = function(input)
input = input:gsub("\\", "\\\\") input = input:gsub("\\", "\\\\")
input = input:gsub("\"", "\\\"") input = input:gsub("\"", "\\\"")