Files
tessesframework/apps/ttorrentcreate.cpp
T
tesses50 dbeae862c5
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-arm:latest, arm-linux-gnueabihf, arm7, fw13-ubuntu-latest) (push) Failing after 38s
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-x64:latest, x86_64-linux-gnu, amd64, msi-walmart) (push) Failing after 41s
Build and Deploy on Tag / 🔨 Build for PowerPC (push) Failing after 43s
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-arm64:latest, aarch64-linux-gnu, arm64, msi-walmart) (push) Failing after 42s
Build and Deploy on Tag / 🔨 Build win32 and update the tap 🍺 (push) Failing after 45s
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-x86:latest, i386-linux-gnu, 386, asrock) (push) Failing after 47s
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-riscv64:latest, riscv64-linux-gnu, riscv64, asrock) (push) Failing after 1m0s
Fixed a stoll bug that was there since day one, html parser, fix pkgconfig
2026-09-22 11:09:50 -05:00

73 lines
2.7 KiB
C++

#include "TessesFramework/TessesFramework.hpp"
using namespace Tesses::Framework;
using namespace Tesses::Framework::Streams;
using namespace Tesses::Framework::Filesystem;
using namespace Tesses::Framework::Serialization::Bencode;
using namespace Tesses::Framework::TextStreams;
using namespace Tesses::Framework::BitTorrent;
void usage(Args &args) {
std::cout << "USAGE: " << args.filename
<< " [options] torrent_contents torrent_file.torrent" << std::endl
<< std::endl;
std::cout << "OPTIONS:" << std::endl;
std::cout << "tracker: torrent tracker url (require at least one)"
<< std::endl;
std::cout << "webseed: url for web seeding" << std::endl;
std::cout << "comment: set the comment" << std::endl;
std::cout << "created_by: set the created by field, defaults to "
"TessesFrameworkTorrent"
<< std::endl;
std::cout << "piece_length: set the piece length, defaults to " +
std::to_string(DEFAULT_PIECE_LENGTH)
<< std::endl
<< std::endl;
std::cout << "FLAGS:" << std::endl;
std::cout << "help: bring this help message up" << std::endl;
std::cout << "private: enable private tracker flag" << std::endl;
exit(1);
}
int main(int argc, char **argv) {
TF_Init();
std::vector<BeString> webseeds;
std::vector<BeString> trackers;
bool isPrivate = false;
int64_t pieceLength = DEFAULT_PIECE_LENGTH;
std::string comment = "";
std::string created_by = "TessesFrameworkTorrent";
Args args(argc, argv);
if (args.positional.size() < 2)
usage(args);
int64_t num;
for (auto &opt : args.options) {
if (opt.first == "tracker")
trackers.push_back(opt.second);
else if (opt.first == "webseed")
webseeds.push_back(opt.second);
else if (opt.first == "comment")
comment = opt.second;
else if (opt.first == "created_by")
created_by = opt.second;
else if (opt.first == "piece_length" &&
Serialization::BitConverter::TryParseSigned(opt.second, num))
pieceLength = num;
}
for (auto &flag : args.flags) {
if (flag == "help")
usage(args);
if (flag == "private")
isPrivate = true;
}
if (trackers.empty())
usage(args);
{
auto torrent_file_stream = LocalFS->OpenFile(args.positional[1], "wb");
TorrentFile::CreateTorrent(torrent_file_stream, trackers, webseeds,
LocalFS, args.positional[0], isPrivate,
pieceLength, comment, created_by);
}
return 0;
}