-
Notifications
You must be signed in to change notification settings - Fork 2
/
GameManager.nim
33 lines (28 loc) · 1.01 KB
/
GameManager.nim
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
import os
import std/strutils
const downloadPath = "download/"
const gamePath = "games/"
const gameName = "TerasologyOmega.zip"
proc install_game*(version: string) =
echo "开始安装游戏: " & version
echo "调用aardio的外部解压器!"
var zip = downloadPath & version & "/" & gameName
var outDir = gamePath & version
var exitCode = execShellCmd("Unpacker.exe " & zip & " " & outDir)
if exitCode == 0: echo "游戏安装完成: " & version
else: echo "安装错误!代码: " & $exitCode
proc uninstall_game*(version: string) =
echo "开始卸载游戏:" & version
var dir = gamePath & version
removeDir(dir)
echo "游戏卸载完成"
proc list_installed*() =
#echo "已安装的游戏:"
for game in walkDir("games"):
var p = game.path
echo p.split("games\\")[1]
# 先解压到缓存 再去复制
proc unpack*(version: string): int =
var zip = downloadPath & version & "/" & gameName
var exitCode = execShellCmd("Unpacker.exe " & zip & " " & "cache/" & version)
return exitCode