aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/fs/lua.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua
index 8640b01a..37e1bffc 100644
--- a/src/luarocks/fs/lua.lua
+++ b/src/luarocks/fs/lua.lua
@@ -839,6 +839,24 @@ end
839-- Other functions 839-- Other functions
840--------------------------------------------------------------------- 840---------------------------------------------------------------------
841 841
842if lfs_ok and not fs_lua.make_temp_dir then
843
844function fs_lua.make_temp_dir(name_pattern)
845 assert(type(name_pattern) == "string")
846 name_pattern = dir.normalize(name_pattern)
847
848 local pattern = (os.getenv("TMPDIR") or os.getenv("TEMP") or "/tmp") .. "/luarocks_" .. name_pattern:gsub("/", "_") .. "-"
849
850 while true do
851 local name = pattern .. tostring(math.random(10000000))
852 if lfs.mkdir(name) then
853 return name
854 end
855 end
856end
857
858end
859
842--- Apply a patch. 860--- Apply a patch.
843-- @param patchname string: The filename of the patch. 861-- @param patchname string: The filename of the patch.
844-- @param patchdata string or nil: The actual patch as a string. 862-- @param patchdata string or nil: The actual patch as a string.