From 4f565f32679530d4bb009b5f9b88a39deb10f405 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Fri, 20 Sep 2013 20:53:25 +0200 Subject: remove reg files no longer needed after install --- win32/bin/LuaRocks.reg.lua | 51 +++++++++++++++++++++++++++++++++++++++++++ win32/bin/create_reg_file.lua | 51 ------------------------------------------- 2 files changed, 51 insertions(+), 51 deletions(-) create mode 100644 win32/bin/LuaRocks.reg.lua delete mode 100644 win32/bin/create_reg_file.lua (limited to 'win32') diff --git a/win32/bin/LuaRocks.reg.lua b/win32/bin/LuaRocks.reg.lua new file mode 100644 index 00000000..2eb7583a --- /dev/null +++ b/win32/bin/LuaRocks.reg.lua @@ -0,0 +1,51 @@ +-- Call this file using its full path and the template file as a parameter; +-- +-- C:\> lua.exe "create_reg_file.lua" "c:\luarocks\2.0\LuaRocks.reg.template" +-- +-- it will strip the ".template" extension and write to that file the +-- template contents, where "" will be replaced by the path +-- to LuaRocks (including the trailing backslash) + + + +-- Check argument +local f = (arg or {})[1] +if not f then + print("must provide template file on command line") + os.exit(1) +end + +-- cleanup filepath, remove all double backslashes +while f:match("\\\\") do + f = f:gsub("\\\\", "\\") +end + +-- extract path and name from argument +local p = "" +local ni = f +for i = #f, 1, -1 do + if f:sub(i,i) == "\\" then + ni = f:sub(i+1) + p = f:sub(1, i) + break + end +end + +-- create output name +local no = ni:gsub("%.template","") + +-- create path substitute; escape backslash by doubles +local ps = p:gsub("\\", "\\\\") + +-- read template +local fh = io.open(f) +local content = fh:read("*a") +fh:close() + +-- fill template +content = content:gsub("%", ps) + +-- write destination file +fh = io.open(p..no, "w+") +fh:write(content) +fh:close() diff --git a/win32/bin/create_reg_file.lua b/win32/bin/create_reg_file.lua deleted file mode 100644 index 2eb7583a..00000000 --- a/win32/bin/create_reg_file.lua +++ /dev/null @@ -1,51 +0,0 @@ --- Call this file using its full path and the template file as a parameter; --- --- C:\> lua.exe "create_reg_file.lua" "c:\luarocks\2.0\LuaRocks.reg.template" --- --- it will strip the ".template" extension and write to that file the --- template contents, where "" will be replaced by the path --- to LuaRocks (including the trailing backslash) - - - --- Check argument -local f = (arg or {})[1] -if not f then - print("must provide template file on command line") - os.exit(1) -end - --- cleanup filepath, remove all double backslashes -while f:match("\\\\") do - f = f:gsub("\\\\", "\\") -end - --- extract path and name from argument -local p = "" -local ni = f -for i = #f, 1, -1 do - if f:sub(i,i) == "\\" then - ni = f:sub(i+1) - p = f:sub(1, i) - break - end -end - --- create output name -local no = ni:gsub("%.template","") - --- create path substitute; escape backslash by doubles -local ps = p:gsub("\\", "\\\\") - --- read template -local fh = io.open(f) -local content = fh:read("*a") -fh:close() - --- fill template -content = content:gsub("%", ps) - --- write destination file -fh = io.open(p..no, "w+") -fh:write(content) -fh:close() -- cgit v1.2.3-55-g6feb