package main import ( "crypto/sha1" "encoding/hex" "flag" "fmt" "os" platformpvf "longheng.io/server/internal/platform/pvf" ) func main() { pvfPath := flag.String("pvf", "", "input PVF") outPath := flag.String("out", "", "output list file") flag.Parse() if *pvfPath == "" || *outPath == "" { fmt.Println("need -pvf and -out") return } archive, err := platformpvf.Open(*pvfPath) if err != nil { panic(err) } f, err := os.Create(*outPath) if err != nil { panic(err) } defer f.Close() count := 0 archive.RangePaths(func(path string) bool { file, ok := archive.FindFile(path) if !ok { return true } raw, err := archive.FileRaw(file.Index) if err != nil { return true } sum := sha1.Sum(raw) fmt.Fprintf(f, "%s\t%d\t%s\n", path, len(raw), hex.EncodeToString(sum[:])) count++ return true }) fmt.Println("files:", count) }