1 Star 0 Fork 5

看这场人来人往/PathOfBuildingCN17173

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
UpdateApply.lua 1012 Bytes
一键复制 编辑 原始数据 按行查看 历史
lucifering 提交于 2018-07-09 10:24 . [ADD]初始化项目
#@
-- 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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hunterXX/PathOfBuildingCN17173.git
git@gitee.com:hunterXX/PathOfBuildingCN17173.git
hunterXX
PathOfBuildingCN17173
PathOfBuildingCN17173
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385