package gorrent import ( "github.com/anacrolix/torrent/metainfo" ) type FileInfo struct { Length int64 Path []string PathUTF8 []string } type Info struct { Name string Length int64 Source string Files []*FileInfo // } func (o *Info) LoadFile(path string) error { meta, err := metainfo.LoadFromFile(path) if err != nil { return err } i, err := meta.UnmarshalInfo() o.Name = i.Name o.Length = i.Length o.Source = i.Source for _, fi := range i.Files { o.Files = append(o.Files, &FileInfo{ Length: fi.Length, Path: fi.Path, PathUTF8: fi.PathUTF8, }) } return err }