1
0
mirror of https://github.com/skywind3000/z.lua synced 2026-03-21 23:29:48 +00:00

fix: no more lua_XXXXXX temp files

This commit is contained in:
Heyward Fann
2019-02-01 13:21:55 +08:00
parent 90996309f3
commit ddadb20521

7
z.lua
View File

@@ -525,7 +525,9 @@ function math.random_init()
if rnd ~= nil then
seed = seed .. rnd
end
seed = seed .. os.tmpname()
local tmpname = os.tmpname()
seed = seed .. tmpname
os.remove(tmpname)
local number = 0
for i = 1, seed:len() do
local k = string.byte(seed:sub(i, i))
@@ -620,8 +622,7 @@ function data_save(filename, M)
else
math.random_init()
tmpname = filename .. '.' .. math.random_string(6)
local sub = (os.tmpname()):sub(-6, -1):gsub('[\\/:~]', '')
tmpname = tmpname .. sub .. tostring(os.time())
tmpname = tmpname .. tostring(os.time())
local rnd = os.getenv('_ZL_RANDOM')
tmpname = tmpname .. '' .. (rnd and rnd or '')
-- print('tmpname: '..tmpname)