Builder

class Builder(name: String, pieceLength: Int)

Fluent builder that collects files (path + size) and the torrent name, then produces a CreateTorrent. This is the convenience layer over constructing a FileStorage directly, analogous to libtorrent's add_files + file_storage feeding create_torrent.

Offsets are assigned automatically in insertion order. For a multi-file torrent, file paths are stored as name/<relative path> so they round-trip through TorrentInfo.

Constructors

Link copied to clipboard
constructor(name: String, pieceLength: Int)

Functions

Link copied to clipboard
fun addFile(relPath: String, size: Long, isPadFile: Boolean = false, symlinkTarget: String? = null): CreateTorrent.Builder

Adds a file. relPath is relative to the torrent root (no leading name); for a single-file torrent add exactly one file whose relPath equals the torrent name (or empty, treated as the name).

Link copied to clipboard
fun build(v1Only: Boolean = false, v2Only: Boolean = false): CreateTorrent

Builds the CreateTorrent from the collected files.

Link copied to clipboard

Builds the immutable FileStorage from the collected specs.