57
57
boost::filesystem::path::default_name_check(boost::filesystem::no_check);
60
#ifndef BOOST_NO_EXCEPTIONS
65
int size = file_size(argv[1]);
66
if (size > 10 * 1000000)
68
std::cerr << "file too big (" << size << "), aborting\n";
71
std::vector<char> buf(size);
72
std::ifstream(argv[1], std::ios_base::binary).read(&buf[0], size);
74
int ret = lazy_bdecode(&buf[0], &buf[0] + buf.size(), e);
78
std::cerr << "invalid bencoding: " << ret << std::endl;
82
std::cout << "\n\n----- raw info -----\n\n";
83
std::cout << e << std::endl;
87
// print info about torrent
88
std::cout << "\n\n----- torrent file info -----\n\n";
89
std::cout << "nodes:\n";
90
typedef std::vector<std::pair<std::string, int> > node_vec;
91
node_vec const& nodes = t.nodes();
92
for (node_vec::const_iterator i = nodes.begin(), end(nodes.end());
95
std::cout << i->first << ":" << i->second << "\n";
97
std::cout << "trackers:\n";
98
for (std::vector<announce_entry>::const_iterator i = t.trackers().begin();
99
i != t.trackers().end(); ++i)
101
std::cout << i->tier << ": " << i->url << "\n";
104
std::cout << "number of pieces: " << t.num_pieces() << "\n";
105
std::cout << "piece length: " << t.piece_length() << "\n";
106
std::cout << "info hash: " << t.info_hash() << "\n";
107
std::cout << "comment: " << t.comment() << "\n";
108
std::cout << "created by: " << t.creator() << "\n";
109
std::cout << "magnet link: " << make_magnet_uri(t) << "\n";
110
std::cout << "name: " << t.name() << "\n";
111
std::cout << "files:\n";
113
for (torrent_info::file_iterator i = t.begin_files();
114
i != t.end_files(); ++i, ++index)
116
int first = t.map_file(index, 0, 0).piece;
117
int last = t.map_file(index, (std::max)(i->size - 1, size_type(0)), 1).piece;
118
std::cout << " " << std::setw(11) << i->size
119
<< " " << i->path.string() << "[ " << first << ", "
123
#ifndef BOOST_NO_EXCEPTIONS
125
catch (std::exception& e)
127
std::cout << e.what() << "\n";
60
int size = file_size(argv[1]);
61
if (size > 10 * 1000000)
63
std::cerr << "file too big (" << size << "), aborting\n";
66
std::vector<char> buf(size);
67
std::ifstream(argv[1], std::ios_base::binary).read(&buf[0], size);
69
int ret = lazy_bdecode(&buf[0], &buf[0] + buf.size(), e);
73
std::cerr << "invalid bencoding: " << ret << std::endl;
77
std::cout << "\n\n----- raw info -----\n\n";
78
std::cout << print_entry(e) << std::endl;
81
torrent_info t(e, ec);
84
std::cout << ec.message() << std::endl;
88
// print info about torrent
89
std::cout << "\n\n----- torrent file info -----\n\n";
90
std::cout << "nodes:\n";
91
typedef std::vector<std::pair<std::string, int> > node_vec;
92
node_vec const& nodes = t.nodes();
93
for (node_vec::const_iterator i = nodes.begin(), end(nodes.end());
96
std::cout << i->first << ":" << i->second << "\n";
98
std::cout << "trackers:\n";
99
for (std::vector<announce_entry>::const_iterator i = t.trackers().begin();
100
i != t.trackers().end(); ++i)
102
std::cout << i->tier << ": " << i->url << "\n";
105
std::cout << "number of pieces: " << t.num_pieces() << "\n";
106
std::cout << "piece length: " << t.piece_length() << "\n";
108
to_hex((char const*)&t.info_hash()[0], 20, ih);
109
std::cout << "info hash: " << ih << "\n";
110
std::cout << "comment: " << t.comment() << "\n";
111
std::cout << "created by: " << t.creator() << "\n";
112
std::cout << "magnet link: " << make_magnet_uri(t) << "\n";
113
std::cout << "name: " << t.name() << "\n";
114
std::cout << "files:\n";
116
for (torrent_info::file_iterator i = t.begin_files();
117
i != t.end_files(); ++i, ++index)
119
int first = t.map_file(index, 0, 0).piece;
120
int last = t.map_file(index, (std::max)(i->size-1, size_type(0)), 0).piece;
121
std::cout << " " << std::setw(11) << i->size
123
<< (i->pad_file?'p':'-')
124
<< (i->executable_attribute?'x':'-')
125
<< (i->hidden_attribute?'h':'-')
126
<< (i->symlink_attribute?'l':'-')
128
<< "[ " << std::setw(4) << first << ", " << std::setw(4) << last << " ]\t"
129
<< i->path.string() ;
130
if (i->symlink_attribute)
131
std::cout << " -> " << i->symlink_path.string();
132
std::cout << std::endl;