metainfo/fileinfo.go | 5 +++-- t.go | 8 +++++++- diff --git a/metainfo/fileinfo.go b/metainfo/fileinfo.go index 4b72d12d81edbae8879edd1ac9794b6e1b0ed0b2..58073a1bbf715a07877fbc8bd0cf517cde7319fa 100644 --- a/metainfo/fileinfo.go +++ b/metainfo/fileinfo.go @@ -4,8 +4,9 @@ import "strings" // 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"` + Path []string `bencode:"path"` + PathUTF8 []string `bencode:"path.utf-8,omitempty"` } func (fi *FileInfo) DisplayPath(info *Info) string { diff --git a/t.go b/t.go index 6b553f96e34ec88593ac12cb119fc7104dc03db3..92a265f15bcee20b4a4d7d23db3bdd50cfa78c2d 100644 --- a/t.go +++ b/t.go @@ -189,9 +189,15 @@ func (t *Torrent) initFiles() { var offset int64 t.files = new([]*File) for _, fi := range t.info.UpvertedFiles() { + var path []string + if len(fi.PathUTF8) != 0 { + path = fi.PathUTF8 + } else { + path = fi.Path + } *t.files = append(*t.files, &File{ t, - strings.Join(append([]string{t.info.Name}, fi.Path...), "/"), + strings.Join(append([]string{t.info.Name}, path...), "/"), offset, fi.Length, fi,