Customized fork of github.com/rxi/lite

Simplified implementation of `core.temp_filename()`

rxi 74755f5b e7cf551e

Changed files
+6 -12
data
core
+6 -12
data/core/init.lua
··· 126 126 end 127 127 128 128 129 - math.randomseed(system.get_time() * 1000) 130 - 131 - local function uid() 132 - return string.gsub("xxxxxx", ".", function() 133 - local chars = "0123456789abcdefghijklmnopqrstuvwxyz" 134 - local n = math.random(#chars) 135 - return chars:sub(n, n) 136 - end) 137 - end 138 - 139 - local temp_file_prefix = ".temp_" .. uid() 129 + local temp_uid = (system.get_time() * 1000) % 0xffffffff 130 + local temp_file_prefix = string.format(".lite_temp_%08x", temp_uid) 131 + local temp_file_counter = 0 140 132 141 133 local function delete_temp_files() 142 134 for _, filename in ipairs(system.list_dir(EXEDIR)) do ··· 147 139 end 148 140 149 141 function core.temp_filename(ext) 150 - return EXEDIR .. PATHSEP .. temp_file_prefix .. uid() .. (ext or "") 142 + temp_file_counter = temp_file_counter + 1 143 + return EXEDIR .. PATHSEP .. temp_file_prefix 144 + .. string.format("%06x", temp_file_counter) .. (ext or "") 151 145 end 152 146 153 147