Skip to content

Commit f60ee39

Browse files
committed
Update install.lua
1 parent d9aa228 commit f60ee39

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

install.lua

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import("net.http.download")
22
import("utils.archive.extract")
33

4-
local function movefilesinfolder(src, dest)
4+
local function movefilesinfolder(src, dest, callback)
55
print('create folder :' .. dest)
66
os.mkdir(dest)
77
print('move folder :' .. src .. " to folder:" .. dest)
@@ -10,13 +10,15 @@ local function movefilesinfolder(src, dest)
1010

1111
if os.isdir(luafile) then
1212
-- print('folder:' .. luafile)
13-
movefilesinfolder(luafile, path.join(dest, path.filename(luafile)))
13+
movefilesinfolder(luafile, path.join(dest, path.filename(luafile)),
14+
callback)
1415

1516
else
1617
-- print('file:' .. luafile)
1718
print('move file :' .. luafile .. " to folder:" .. dest)
1819

1920
os.mv(luafile, dest)
21+
callback(path.join(dest, path.filename(luafile)))
2022

2123
end
2224

@@ -28,26 +30,33 @@ function main()
2830
local name = "leetcode-treenode-cpp"
2931
local version = "1.1.8"
3032
local folder = name .. "-" .. version
31-
local file = path.join('downloads', folder .. '.tar.gz')
32-
if not os.exists(file) then
33+
local archivefile = path.join('downloads', folder .. '.tar.gz')
34+
if not os.exists(archivefile) then
3335
local url = 'https://ghproxy.com/https://github.com/masx200/' .. name ..
3436
'/archive/' .. version .. '.tar.gz'
35-
print('download url:' .. url .. " to file:" .. file)
36-
download(url, file)
37+
print('download url:' .. url .. " to file:" .. archivefile)
38+
download(url, archivefile)
3739
end
3840
local outputdir = path.join('downloads', folder)
3941
if os.exists(outputdir) then
4042
print("remove folder:" .. outputdir)
4143
os.rmdir(outputdir)
4244
end
43-
print('extract file:' .. file .. " to folder:" .. outputdir)
44-
extract(file, outputdir)
45+
print('extract file:' .. archivefile .. " to folder:" .. outputdir)
46+
extract(archivefile, outputdir)
4547
local src = path.join('downloads', folder, folder)
4648
if os.exists(name) then
4749
print("remove folder:" .. name)
4850
os.rmdir(name)
4951
end
50-
51-
movefilesinfolder(src, name)
52-
52+
local installedlistfile = io.open(archivefile .. '.list', "w")
53+
if nil == installedlistfile then
54+
print("open file: " .. archivefile .. '.list' .. " fail")
55+
return
56+
end
57+
movefilesinfolder(src, name, function(installedfile)
58+
installedlistfile:write(installedfile)
59+
installedlistfile:write("\n")
60+
end)
61+
installedlistfile:close()
5362
end

0 commit comments

Comments
 (0)