Browse Source

解压zip的时候从监视目录的根开始

master
453530270@qq.com 2 years ago
parent
commit
947849ba50
  1. 3
      fsv2/README.md
  2. BIN
      fsv2/fstc
  3. 7
      fsv2/util/util.go

3
fsv2/README.md

@ -5,3 +5,6 @@
被动更新模式 被动更新模式
接收文件 --》查找文件并备份 --》 文件覆盖 接收文件 --》查找文件并备份 --》 文件覆盖
1、接收的zip文件存放在files 下面
2、单文件能自动重命名原来的文件

BIN
fsv2/fstc

Binary file not shown.

7
fsv2/util/util.go

@ -9,6 +9,7 @@ import (
"path" "path"
"path/filepath" "path/filepath"
"strings" "strings"
"xtcfs/config"
) )
/** /**
@ -129,10 +130,14 @@ func DecompressZip(zpFname string) error {
return err return err
} }
dir := filepath.Dir(zpFname) dir := filepath.Dir(zpFname)
fmt.Printf("zip file path:%s\n", dir)
defer archive.Close() defer archive.Close()
// 遍历目录 // 遍历目录
for _, f := range archive.File { for _, f := range archive.File {
filePath := filepath.Join(dir, f.Name) // zip 解压的时候,路径为监听的路径
filePath := filepath.Join(config.G.FilePath, f.Name)
//filePath := filepath.Join(dir, f.Name)
if f.FileInfo().IsDir() { if f.FileInfo().IsDir() {
os.MkdirAll(filePath, os.ModePerm) os.MkdirAll(filePath, os.ModePerm)
continue continue

Loading…
Cancel
Save