forked from PathOfBuildingCommunity/PathOfBuilding
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateApply.lua
More file actions
Latest commit
46 lines (45 loc) · 1012 Bytes
/
Copy pathUpdateApply.lua
File metadata and controls
46 lines (45 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#@
-- Path of Building
--
-- Module: Update Apply
-- Applies updates.
--
localopFileName=...
print("Applying update...")
localopFile=io.open(opFileName, "r")
ifnotopFilethen
print("No operations list present.\n")
return
end
locallines= { }
forlineinopFile:lines() do
table.insert(lines, line)
end
opFile:close()
os.remove(opFileName)
for_, lineinipairs(lines) do
localop, args=line:match("(%a+) ?(.*)")
ifop=="move" then
localsrc, dst=args:match('"(.*)" "(.*)"')
print("Updating '"..dst.."'")
localsrcFile=io.open(src, "rb")
assert(srcFile, "couldn't open "..src)
localdstFile
whilenotdstFiledo
dstFile=io.open(dst, "w+b")
end
ifdstFilethen
dstFile:write(srcFile:read("*a"))
dstFile:close()
end
srcFile:close()
os.remove(src)
elseifop=="delete" then
localfile=args:match('"(.*)"')
print("Deleting '"..file.."'")
os.remove(file)
elseifop=="start" then
localtarget=args:match('"(.*)"')
SpawnProcess(target)
end
end