a41f938cec
As we have seen, dependencies version can prevent the build. We should user lock versions on dependencies that we know work: * Packages are vendored * Add Godep support * Added addtional install step in readme * Fix travis build error
27 lignes
552 o
Go
27 lignes
552 o
Go
package metainfo
|
|
|
|
import "strings"
|
|
|
|
// Information specific to a single file inside the MetaInfo structure.
|
|
type FileInfo struct {
|
|
Length int64 `bencode:"length"`
|
|
Path []string `bencode:"path"`
|
|
}
|
|
|
|
func (fi *FileInfo) DisplayPath(info *Info) string {
|
|
if info.IsDir() {
|
|
return strings.Join(fi.Path, "/")
|
|
} else {
|
|
return info.Name
|
|
}
|
|
}
|
|
|
|
func (me FileInfo) Offset(info *Info) (ret int64) {
|
|
for _, fi := range info.UpvertedFiles() {
|
|
if me.DisplayPath(info) == fi.DisplayPath(info) {
|
|
return
|
|
}
|
|
ret += fi.Length
|
|
}
|
|
panic("not found")
|
|
}
|