57 Star 297 Fork 71

幸福的闪电 / PathOfBuildingCN17173

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
UpdateApply.lua 1012 Bytes
一键复制 编辑 原始数据 按行查看 历史
Tai 提交于 2021-08-10 09:24 . Initial commit
#@
-- Path of Building
--
-- Module: Update Apply
-- Applies updates.
--
local opFileName = ...
print("Applying update...")
local opFile = io.open(opFileName, "r")
if not opFile then
print("No operations list present.\n")
return
end
local lines = { }
for line in opFile:lines() do
table.insert(lines, line)
end
opFile:close()
os.remove(opFileName)
for _, line in ipairs(lines) do
local op, args = line:match("(%a+) ?(.*)")
if op == "move" then
local src, dst = args:match('"(.*)" "(.*)"')
print("Updating '"..dst.."'")
local srcFile = io.open(src, "rb")
assert(srcFile, "couldn't open "..src)
local dstFile
while not dstFile do
dstFile = io.open(dst, "w+b")
end
if dstFile then
dstFile:write(srcFile:read("*a"))
dstFile:close()
end
srcFile:close()
os.remove(src)
elseif op == "delete" then
local file = args:match('"(.*)"')
print("Deleting '"..file.."'")
os.remove(file)
elseif op == "start" then
local target = args:match('"(.*)"')
SpawnProcess(target)
end
end
Lua
1
https://gitee.com/echo28/PathOfBuildingCN17173.git
git@gitee.com:echo28/PathOfBuildingCN17173.git
echo28
PathOfBuildingCN17173
PathOfBuildingCN17173
main

搜索帮助