-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
49 lines (42 loc) · 1021 Bytes
/
main.go
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
47
48
49
package main
import (
"flag"
"fmt"
"github.com/xupin/wd-pak/core"
"github.com/xupin/wd-pak/utils"
)
var (
t int
filePath, folderPath string
)
func main() {
flag.IntVar(&t, "t", 0, "1:解包\n2:打包")
flag.StringVar(&filePath, "f", "", "pak文件路径")
flag.StringVar(&folderPath, "o", "", "输出路径")
flag.Parse()
if t < 1 || len(filePath) == 0 || len(folderPath) == 0 {
fmt.Printf("请输入 -h 查看说明\n")
return
}
// 处理最后一个字符
if folderPath[len(folderPath)-1:] == "/" {
folderPath = folderPath[:len(folderPath)-1]
}
if t == 1 {
if !utils.Exists(filePath) {
fmt.Printf("pak文件 %s 不存在 \n", filePath)
return
}
pakReader := core.NewReader(filePath, folderPath)
pakReader.DeCompress()
pakReader.Close()
} else if t == 2 {
if !utils.Exists(folderPath) {
fmt.Printf("目录 %s 不存在 \n", folderPath)
return
}
pakWriter := core.NewWriter(folderPath, filePath)
pakWriter.Compress()
pakWriter.Close()
}
}