webmcp
view framework/env/tempstore/pop.lua @ 469:dd6ef55cd59d
Changed Lua version from 5.2 to 5.3 in Makefile.options
| author | jbe | 
|---|---|
| date | Wed May 24 20:44:46 2017 +0200 (2017-05-24) | 
| parents | 2cb27106aa73 | 
| children | 
 line source
     1 --[[--
     2 blob =          -- loaded string
     3 tempstore.pop(
     4   key           -- key as returned by tempstore.save(...)
     5 )
     7 This function restores data, which had been stored temporarily by tempstore.save(...). After loading the data, it is deleted from the tempstore automatically.
     9 --]]--
    11 function tempstore.pop(key)
    12   local filename = encode.file_path(
    13     WEBMCP_BASE_PATH, 'tmp', "tempstore-" .. key .. ".tmp"
    14   )
    15   local file = io.open(filename, "r")
    16   if not file then return nil end
    17   local blob = file:read("*a")
    18   io.close(file)
    19   os.remove(filename)
    20   return blob
    21 end
