4 "github.com/anacrolix/torrent/metainfo"
7 func NewFileWithCompletion(baseDir string, completion PieceCompletion) ClientImplCloser {
8 return NewFileWithCustomPathMakerAndCompletion(baseDir, nil, completion)
11 // File storage with data partitioned by infohash.
12 func NewFileByInfoHash(baseDir string) ClientImplCloser {
13 return NewFileWithCustomPathMaker(baseDir, infoHashPathMaker)
16 // Deprecated: Allows passing a function to determine the path for storing torrent data. The
17 // function is responsible for sanitizing the info if it uses some part of it (for example
18 // sanitizing info.Name).
19 func NewFileWithCustomPathMaker(baseDir string, pathMaker func(baseDir string, info *metainfo.Info, infoHash metainfo.Hash) string) ClientImplCloser {
20 return NewFileWithCustomPathMakerAndCompletion(baseDir, pathMaker, pieceCompletionForDir(baseDir))
23 // Deprecated: Allows passing custom PieceCompletion
24 func NewFileWithCustomPathMakerAndCompletion(
26 pathMaker TorrentDirFilePathMaker,
27 completion PieceCompletion,
29 return NewFileOpts(NewFileClientOpts{
30 ClientBaseDir: baseDir,
31 TorrentDirMaker: pathMaker,
32 PieceCompletion: completion,