webmcp

diff framework/env/tempstore/pop.lua @ 0:9fdfb27f8e67

Version 1.0.0
author jbe/bsw
date Sun Oct 25 12:00:00 2009 +0100 (2009-10-25)
parents
children 2cb27106aa73
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/framework/env/tempstore/pop.lua	Sun Oct 25 12:00:00 2009 +0100
     1.3 @@ -0,0 +1,21 @@
     1.4 +--[[--
     1.5 +blob =          -- loaded string
     1.6 +tempstore.pop(
     1.7 +  key           -- key as returned by tempstore.save(...)
     1.8 +)
     1.9 +
    1.10 +This function restores data, which had been stored temporarily by tempstore.save(...). After loading the data, it is deleted from the tempstore automatically.
    1.11 +
    1.12 +--]]--
    1.13 +
    1.14 +function tempstore.pop(key)
    1.15 +  local filename = encode.file_path(
    1.16 +    request.get_app_basepath(), 'tmp', "tempstore-" .. key .. ".tmp"
    1.17 +  )
    1.18 +  local file = io.open(filename, "r")
    1.19 +  if not file then return nil end
    1.20 +  local blob = file:read("*a")
    1.21 +  io.close(file)
    1.22 +  os.remove(filename)
    1.23 +  return blob
    1.24 +end

Impressum / About Us