-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathziplist.go
More file actions
45 lines (42 loc) · 828 Bytes
/
ziplist.go
File metadata and controls
45 lines (42 loc) · 828 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
package main
import (
"archive/zip"
"fmt"
"log/slog"
)
type ZipList struct {
}
func (cmd *ZipList) Execute(args []string) (err error) {
init_log()
var zipfile *zip.ReadCloser
filename := archiveFilename()
zipfile, err = zip.OpenReader(filename)
if err != nil {
slog.Error("open error", "error", err)
return err
}
defer zipfile.Close()
typemap := map[uint16]string{
zip.Store: "S",
zip.Deflate: "D",
Brotli: "B",
Bzip2: "b",
Lzma: "L",
Xz: "X",
Zstd: "Z",
Mp3: "M",
Jpeg: "J",
Webpack: "W",
}
for _, i := range zipfile.File {
pfx := "?"
if i.FileInfo().IsDir() {
pfx = "/"
}
if v, ok := typemap[i.Method]; ok {
pfx = v
}
fmt.Println(pfx, i.Name, i.CompressedSize64, i.UncompressedSize64, i.Comment)
}
return nil
}