// Information specific to a single file inside the MetaInfo structure.
type FileInfo struct {
- Length int64 `bencode:"length"`
- Path []string `bencode:"path"`
+ Length int64 `bencode:"length"` // BEP3
+ Path []string `bencode:"path"` // BEP3
+ PathUtf8 []string `bencode:"path.utf-8,omitempty"`
}
func (fi *FileInfo) DisplayPath(info *Info) string {
if info.IsDir() {
- return strings.Join(fi.Path, "/")
+ return strings.Join(fi.BestPath(), "/")
} else {
- return info.Name
+ return info.BestName()
}
}
}
panic("not found")
}
+
+func (fi FileInfo) BestPath() []string {
+ if len(fi.PathUtf8) != 0 {
+ return fi.PathUtf8
+ }
+ return fi.Path
+}