Customized fork of github.com/rxi/lite

Added `core.temp_filename()`

rxi 257b9ab7 61a2a2c4

Changed files
+26
data
core
+26
data/core/init.lua
··· 120 120 end 121 121 122 122 123 + math.randomseed(system.get_time() * 1000) 124 + 125 + local function uid() 126 + return string.gsub("xxxxxx", ".", function() 127 + local chars = "0123456789abcdefghijklmnopqrstuvwxyz" 128 + local n = math.random(#chars) 129 + return chars:sub(n, n) 130 + end) 131 + end 132 + 133 + local temp_file_prefix = ".temp_" .. uid() 134 + 135 + local function delete_temp_files() 136 + for _, filename in ipairs(system.list_dir(EXEDIR)) do 137 + if filename:find(temp_file_prefix, 1, true) == 1 then 138 + os.remove(EXEDIR .. PATHSEP .. filename) 139 + end 140 + end 141 + end 142 + 143 + function core.temp_filename(ext) 144 + return EXEDIR .. PATHSEP .. temp_file_prefix .. uid() .. (ext or "") 145 + end 146 + 147 + 123 148 function core.quit(force) 124 149 if force then 150 + delete_temp_files() 125 151 os.exit() 126 152 end 127 153 local dirty_count = 0