2004-10-10 02:42:48 +02:00
|
|
|
/*
|
|
|
|
|
2006-11-14 16:53:38 +01:00
|
|
|
Copyright (c) 2006, Arvid Norberg
|
2004-10-10 02:42:48 +02:00
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in
|
|
|
|
the documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the author nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived
|
|
|
|
from this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libtorrent/entry.hpp"
|
|
|
|
#include "libtorrent/bencode.hpp"
|
|
|
|
#include "libtorrent/torrent_info.hpp"
|
|
|
|
#include "libtorrent/file.hpp"
|
|
|
|
#include "libtorrent/storage.hpp"
|
|
|
|
#include "libtorrent/hasher.hpp"
|
2008-05-20 11:49:40 +02:00
|
|
|
#include "libtorrent/create_torrent.hpp"
|
2009-10-26 02:29:39 +01:00
|
|
|
#include "libtorrent/file.hpp"
|
2012-03-20 04:53:07 +01:00
|
|
|
#include "libtorrent/file_pool.hpp"
|
2015-03-30 06:38:47 +02:00
|
|
|
#include "libtorrent/hex.hpp" // for from_hex
|
2004-10-10 02:42:48 +02:00
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
#include <boost/bind.hpp>
|
2004-10-10 02:42:48 +02:00
|
|
|
|
2015-01-08 21:20:44 +01:00
|
|
|
#ifdef TORRENT_WINDOWS
|
|
|
|
#include <direct.h> // for _getcwd
|
|
|
|
#endif
|
|
|
|
|
2004-10-10 02:42:48 +02:00
|
|
|
using namespace libtorrent;
|
|
|
|
|
2013-07-19 23:41:33 +02:00
|
|
|
int load_file(std::string const& filename, std::vector<char>& v, libtorrent::error_code& ec, int limit = 8000000)
|
|
|
|
{
|
|
|
|
ec.clear();
|
|
|
|
FILE* f = fopen(filename.c_str(), "rb");
|
|
|
|
if (f == NULL)
|
|
|
|
{
|
2015-11-24 06:50:51 +01:00
|
|
|
ec.assign(errno, boost::system::system_category());
|
2013-07-19 23:41:33 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int r = fseek(f, 0, SEEK_END);
|
|
|
|
if (r != 0)
|
|
|
|
{
|
2015-11-24 06:50:51 +01:00
|
|
|
ec.assign(errno, boost::system::system_category());
|
2013-07-19 23:41:33 +02:00
|
|
|
fclose(f);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
long s = ftell(f);
|
|
|
|
if (s < 0)
|
|
|
|
{
|
2015-11-24 06:50:51 +01:00
|
|
|
ec.assign(errno, boost::system::system_category());
|
2013-07-19 23:41:33 +02:00
|
|
|
fclose(f);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s > limit)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = fseek(f, 0, SEEK_SET);
|
|
|
|
if (r != 0)
|
|
|
|
{
|
2015-11-24 06:50:51 +01:00
|
|
|
ec.assign(errno, boost::system::system_category());
|
2013-07-19 23:41:33 +02:00
|
|
|
fclose(f);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
v.resize(s);
|
|
|
|
if (s == 0)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = fread(&v[0], 1, v.size(), f);
|
|
|
|
if (r < 0)
|
|
|
|
{
|
2015-11-24 06:50:51 +01:00
|
|
|
ec.assign(errno, boost::system::system_category());
|
2013-07-19 23:41:33 +02:00
|
|
|
fclose(f);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
if (r != s) return -3;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-01-02 12:11:09 +01:00
|
|
|
std::string branch_path(std::string const& f)
|
|
|
|
{
|
|
|
|
if (f.empty()) return f;
|
|
|
|
|
|
|
|
#ifdef TORRENT_WINDOWS
|
|
|
|
if (f == "\\\\") return "";
|
|
|
|
#endif
|
|
|
|
if (f == "/") return "";
|
|
|
|
|
|
|
|
int len = f.size();
|
|
|
|
// if the last character is / or \ ignore it
|
|
|
|
if (f[len-1] == '/' || f[len-1] == '\\') --len;
|
|
|
|
while (len > 0)
|
|
|
|
{
|
|
|
|
--len;
|
|
|
|
if (f[len] == '/' || f[len] == '\\')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (f[len] == '/' || f[len] == '\\') ++len;
|
|
|
|
return std::string(f.c_str(), len);
|
|
|
|
}
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
// do not include files and folders whose
|
|
|
|
// name starts with a .
|
2009-10-26 02:29:39 +01:00
|
|
|
bool file_filter(std::string const& f)
|
2004-10-10 02:42:48 +02:00
|
|
|
{
|
2015-01-02 12:11:09 +01:00
|
|
|
if (f.empty()) return false;
|
|
|
|
|
|
|
|
char const* first = f.c_str();
|
|
|
|
char const* sep = strrchr(first, '/');
|
|
|
|
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|
|
|
|
char const* altsep = strrchr(first, '\\');
|
2015-04-29 06:33:00 +02:00
|
|
|
if (sep == NULL || altsep > sep) sep = altsep;
|
2015-01-02 12:11:09 +01:00
|
|
|
#endif
|
2015-04-29 06:33:00 +02:00
|
|
|
// if there is no parent path, just set 'sep'
|
|
|
|
// to point to the filename.
|
|
|
|
// if there is a parent path, skip the '/' character
|
|
|
|
if (sep == NULL) sep = first;
|
|
|
|
else ++sep;
|
|
|
|
|
2015-01-02 12:11:09 +01:00
|
|
|
// return false if the first character of the filename is a .
|
2015-04-29 06:33:00 +02:00
|
|
|
if (sep[0] == '.') return false;
|
2015-01-02 12:11:09 +01:00
|
|
|
|
2009-10-26 02:29:39 +01:00
|
|
|
fprintf(stderr, "%s\n", f.c_str());
|
2008-05-28 10:44:40 +02:00
|
|
|
return true;
|
2004-10-10 02:42:48 +02:00
|
|
|
}
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
void print_progress(int i, int num)
|
|
|
|
{
|
2009-10-20 18:44:11 +02:00
|
|
|
fprintf(stderr, "\r%d/%d", i+1, num);
|
2008-05-28 10:44:40 +02:00
|
|
|
}
|
2004-10-10 02:42:48 +02:00
|
|
|
|
2009-01-11 11:32:57 +01:00
|
|
|
void print_usage()
|
|
|
|
{
|
2009-10-20 18:44:11 +02:00
|
|
|
fputs("usage: make_torrent FILE [OPTIONS]\n"
|
2009-01-11 11:32:57 +01:00
|
|
|
"\n"
|
|
|
|
"Generates a torrent file from the specified file\n"
|
|
|
|
"or directory and writes it to standard out\n\n"
|
|
|
|
"OPTIONS:\n"
|
2015-03-21 01:12:40 +01:00
|
|
|
"-m file generate a merkle hash tree torrent.\n"
|
|
|
|
" merkle torrents require client support\n"
|
|
|
|
" the resulting full merkle tree is written to\n"
|
|
|
|
" the specified file\n"
|
|
|
|
"-w url adds a web seed to the torrent with\n"
|
|
|
|
" the specified url\n"
|
|
|
|
"-t url adds the specified tracker to the\n"
|
|
|
|
" torrent. For multiple trackers, specify more\n"
|
|
|
|
" -t options\n"
|
|
|
|
"-c comment sets the comment to the specified string\n"
|
|
|
|
"-C creator sets the created-by field to the specified string\n"
|
|
|
|
"-p bytes enables padding files. Files larger\n"
|
|
|
|
" than bytes will be piece-aligned\n"
|
|
|
|
"-s bytes specifies a piece size for the torrent\n"
|
|
|
|
" This has to be a multiple of 16 kiB\n"
|
|
|
|
"-l Don't follow symlinks, instead encode them as\n"
|
|
|
|
" links in the torrent file\n"
|
|
|
|
"-o file specifies the output filename of the torrent file\n"
|
|
|
|
" If this is not specified, the torrent file is\n"
|
|
|
|
" printed to the standard out, except on windows\n"
|
|
|
|
" where the filename defaults to a.torrent\n"
|
|
|
|
"-r file add root certificate to the torrent, to verify\n"
|
|
|
|
" the HTTPS tracker\n"
|
|
|
|
"-S info-hash add a similar torrent by info-hash. The similar\n"
|
|
|
|
" torrent is expected to share some files with this one\n"
|
|
|
|
"-L collection add a collection name to this torrent. Other torrents\n"
|
|
|
|
" in the same collection is expected to share files\n"
|
|
|
|
" with this one.\n"
|
|
|
|
"-M make the torrent compatible with mutable torrents\n"
|
|
|
|
" this means aligning large files and pad them in order\n"
|
|
|
|
" for piece hashes to uniquely indentify a file without\n"
|
|
|
|
" overlap\n"
|
2009-10-20 18:44:11 +02:00
|
|
|
, stderr);
|
2009-01-11 11:32:57 +01:00
|
|
|
}
|
|
|
|
|
2004-10-10 02:42:48 +02:00
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
using namespace libtorrent;
|
|
|
|
|
2012-10-02 22:43:01 +02:00
|
|
|
std::string creator_str = "libtorrent";
|
2012-10-03 03:55:08 +02:00
|
|
|
std::string comment_str;
|
2008-05-28 10:44:40 +02:00
|
|
|
|
2009-01-11 11:32:57 +01:00
|
|
|
if (argc < 2)
|
2004-10-10 02:42:48 +02:00
|
|
|
{
|
2009-01-11 11:32:57 +01:00
|
|
|
print_usage();
|
2004-10-10 02:42:48 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-12-30 02:59:10 +01:00
|
|
|
#ifndef BOOST_NO_EXCEPTIONS
|
2004-10-10 02:42:48 +02:00
|
|
|
try
|
|
|
|
{
|
2007-12-30 02:59:10 +01:00
|
|
|
#endif
|
2009-01-11 11:32:57 +01:00
|
|
|
std::vector<std::string> web_seeds;
|
|
|
|
std::vector<std::string> trackers;
|
2015-03-21 01:12:40 +01:00
|
|
|
std::vector<std::string> collections;
|
|
|
|
std::vector<sha1_hash> similar;
|
2009-01-11 11:32:57 +01:00
|
|
|
int pad_file_limit = -1;
|
|
|
|
int piece_size = 0;
|
2009-03-13 07:09:39 +01:00
|
|
|
int flags = 0;
|
2011-08-28 23:06:15 +02:00
|
|
|
std::string root_cert;
|
2009-01-11 11:32:57 +01:00
|
|
|
|
2010-03-25 01:50:23 +01:00
|
|
|
std::string outfile;
|
2011-07-30 19:35:22 +02:00
|
|
|
std::string merklefile;
|
2010-03-25 01:50:23 +01:00
|
|
|
#ifdef TORRENT_WINDOWS
|
|
|
|
// don't ever write binary data to the console on windows
|
|
|
|
// it will just be interpreted as text and corrupted
|
|
|
|
outfile = "a.torrent";
|
|
|
|
#endif
|
|
|
|
|
2009-01-11 11:32:57 +01:00
|
|
|
for (int i = 2; i < argc; ++i)
|
|
|
|
{
|
|
|
|
if (argv[i][0] != '-')
|
|
|
|
{
|
|
|
|
print_usage();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (argv[i][1])
|
|
|
|
{
|
|
|
|
case 'w':
|
|
|
|
++i;
|
|
|
|
web_seeds.push_back(argv[i]);
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
++i;
|
|
|
|
trackers.push_back(argv[i]);
|
|
|
|
break;
|
2015-03-21 01:12:40 +01:00
|
|
|
case 'M':
|
|
|
|
flags |= create_torrent::mutable_torrent_support;
|
|
|
|
pad_file_limit = 0x4000;
|
|
|
|
break;
|
2009-01-11 11:32:57 +01:00
|
|
|
case 'p':
|
|
|
|
++i;
|
|
|
|
pad_file_limit = atoi(argv[i]);
|
2009-03-13 07:09:39 +01:00
|
|
|
flags |= create_torrent::optimize;
|
2009-01-11 11:32:57 +01:00
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
++i;
|
|
|
|
piece_size = atoi(argv[i]);
|
|
|
|
break;
|
2009-03-13 07:09:39 +01:00
|
|
|
case 'm':
|
2011-07-30 19:35:22 +02:00
|
|
|
++i;
|
|
|
|
merklefile = argv[i];
|
2009-03-13 07:09:39 +01:00
|
|
|
flags |= create_torrent::merkle;
|
|
|
|
break;
|
2010-03-25 01:50:23 +01:00
|
|
|
case 'o':
|
|
|
|
++i;
|
|
|
|
outfile = argv[i];
|
|
|
|
break;
|
2010-04-01 02:44:29 +02:00
|
|
|
case 'l':
|
|
|
|
flags |= create_torrent::symlinks;
|
|
|
|
break;
|
2012-10-02 22:43:01 +02:00
|
|
|
case 'C':
|
|
|
|
++i;
|
|
|
|
creator_str = argv[i];
|
|
|
|
break;
|
2011-08-28 23:06:15 +02:00
|
|
|
case 'c':
|
2012-10-03 03:55:08 +02:00
|
|
|
++i;
|
|
|
|
comment_str = argv[i];
|
|
|
|
break;
|
|
|
|
case 'r':
|
2011-08-28 23:06:15 +02:00
|
|
|
++i;
|
|
|
|
root_cert = argv[i];
|
|
|
|
break;
|
2015-03-21 01:12:40 +01:00
|
|
|
case 'S':
|
|
|
|
{
|
|
|
|
++i;
|
|
|
|
if (strlen(argv[i]) != 40)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "invalid info-hash for -S. "
|
|
|
|
"Expected 40 hex characters\n");
|
|
|
|
print_usage();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
sha1_hash ih;
|
|
|
|
if (!from_hex(argv[i], 40, (char*)&ih[0]))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "invalid info-hash for -S\n");
|
|
|
|
print_usage();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
similar.push_back(ih);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
++i;
|
|
|
|
collections.push_back(argv[i]);
|
|
|
|
break;
|
2009-01-11 11:32:57 +01:00
|
|
|
default:
|
|
|
|
print_usage();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
file_storage fs;
|
2015-01-02 12:11:09 +01:00
|
|
|
std::string full_path = argv[1];
|
|
|
|
#ifdef TORRENT_WINDOWS
|
|
|
|
if (full_path[1] != ':')
|
|
|
|
#else
|
|
|
|
if (full_path[0] != '/')
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
char cwd[TORRENT_MAX_PATH];
|
|
|
|
#ifdef TORRENT_WINDOWS
|
2015-01-08 21:20:44 +01:00
|
|
|
_getcwd(cwd, sizeof(cwd));
|
2015-01-02 12:11:09 +01:00
|
|
|
full_path = cwd + ("\\" + full_path);
|
|
|
|
#else
|
2015-01-08 21:20:44 +01:00
|
|
|
getcwd(cwd, sizeof(cwd));
|
2015-01-02 12:11:09 +01:00
|
|
|
full_path = cwd + ("/" + full_path);
|
|
|
|
#endif
|
|
|
|
}
|
2004-10-10 02:42:48 +02:00
|
|
|
|
2010-04-01 02:44:29 +02:00
|
|
|
add_files(fs, full_path, file_filter, flags);
|
2009-11-30 01:40:36 +01:00
|
|
|
if (fs.num_files() == 0)
|
|
|
|
{
|
|
|
|
fputs("no files specified.\n", stderr);
|
|
|
|
return 1;
|
|
|
|
}
|
2004-10-10 02:42:48 +02:00
|
|
|
|
2009-03-13 07:09:39 +01:00
|
|
|
create_torrent t(fs, piece_size, pad_file_limit, flags);
|
2012-10-02 22:43:01 +02:00
|
|
|
int tier = 0;
|
2009-01-11 11:32:57 +01:00
|
|
|
for (std::vector<std::string>::iterator i = trackers.begin()
|
2012-10-02 22:43:01 +02:00
|
|
|
, end(trackers.end()); i != end; ++i, ++tier)
|
|
|
|
t.add_tracker(*i, tier);
|
2009-01-11 11:32:57 +01:00
|
|
|
|
|
|
|
for (std::vector<std::string>::iterator i = web_seeds.begin()
|
|
|
|
, end(web_seeds.end()); i != end; ++i)
|
|
|
|
t.add_url_seed(*i);
|
|
|
|
|
2015-03-21 01:12:40 +01:00
|
|
|
for (std::vector<std::string>::iterator i = collections.begin()
|
|
|
|
, end(collections.end()); i != end; ++i)
|
|
|
|
t.add_collection(*i);
|
|
|
|
|
|
|
|
for (std::vector<sha1_hash>::iterator i = similar.begin()
|
|
|
|
, end(similar.end()); i != end; ++i)
|
|
|
|
t.add_similar_torrent(*i);
|
|
|
|
|
2009-04-07 17:06:07 +02:00
|
|
|
error_code ec;
|
2015-01-02 12:11:09 +01:00
|
|
|
set_piece_hashes(t, branch_path(full_path)
|
2009-04-07 17:06:07 +02:00
|
|
|
, boost::bind(&print_progress, _1, t.num_pieces()), ec);
|
|
|
|
if (ec)
|
|
|
|
{
|
2009-10-20 18:44:11 +02:00
|
|
|
fprintf(stderr, "%s\n", ec.message().c_str());
|
2009-04-07 17:06:07 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-10-20 18:44:11 +02:00
|
|
|
fprintf(stderr, "\n");
|
2012-10-02 22:43:01 +02:00
|
|
|
t.set_creator(creator_str.c_str());
|
2012-10-03 03:55:08 +02:00
|
|
|
if (!comment_str.empty())
|
|
|
|
t.set_comment(comment_str.c_str());
|
2004-10-10 02:42:48 +02:00
|
|
|
|
2011-08-28 23:06:15 +02:00
|
|
|
if (!root_cert.empty())
|
|
|
|
{
|
2011-09-05 07:50:41 +02:00
|
|
|
std::vector<char> pem;
|
|
|
|
load_file(root_cert, pem, ec, 10000);
|
|
|
|
if (ec)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "failed to load root certificate for tracker: %s\n", ec.message().c_str());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t.set_root_cert(std::string(&pem[0], pem.size()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-11 11:32:57 +01:00
|
|
|
// create the torrent and print it to stdout
|
2009-10-20 18:44:11 +02:00
|
|
|
std::vector<char> torrent;
|
|
|
|
bencode(back_inserter(torrent), t.generate());
|
2010-03-25 01:50:23 +01:00
|
|
|
FILE* output = stdout;
|
|
|
|
if (!outfile.empty())
|
|
|
|
output = fopen(outfile.c_str(), "wb+");
|
2012-10-02 22:43:01 +02:00
|
|
|
if (output == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "failed to open file \"%s\": (%d) %s\n"
|
|
|
|
, outfile.c_str(), errno, strerror(errno));
|
|
|
|
return 1;
|
|
|
|
}
|
2010-03-25 01:50:23 +01:00
|
|
|
fwrite(&torrent[0], 1, torrent.size(), output);
|
|
|
|
|
|
|
|
if (output != stdout)
|
|
|
|
fclose(output);
|
2009-10-20 18:44:11 +02:00
|
|
|
|
2011-07-30 19:35:22 +02:00
|
|
|
if (!merklefile.empty())
|
|
|
|
{
|
|
|
|
output = fopen(merklefile.c_str(), "wb+");
|
2013-01-21 08:33:48 +01:00
|
|
|
if (output == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "failed to open file \"%s\": (%d) %s\n"
|
|
|
|
, merklefile.c_str(), errno, strerror(errno));
|
|
|
|
return 1;
|
|
|
|
}
|
2011-08-03 10:31:10 +02:00
|
|
|
int ret = fwrite(&t.merkle_tree()[0], 20, t.merkle_tree().size(), output);
|
2014-07-05 16:10:25 +02:00
|
|
|
if (ret != int(t.merkle_tree().size()))
|
2011-07-30 19:35:22 +02:00
|
|
|
{
|
|
|
|
fprintf(stderr, "failed to write %s: (%d) %s\n"
|
|
|
|
, merklefile.c_str(), errno, strerror(errno));
|
|
|
|
}
|
|
|
|
fclose(output);
|
|
|
|
}
|
|
|
|
|
2007-12-30 02:59:10 +01:00
|
|
|
#ifndef BOOST_NO_EXCEPTIONS
|
2004-10-10 02:42:48 +02:00
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2009-10-20 18:44:11 +02:00
|
|
|
fprintf(stderr, "%s\n", e.what());
|
2004-10-10 02:42:48 +02:00
|
|
|
}
|
2007-12-30 02:59:10 +01:00
|
|
|
#endif
|
2004-10-10 02:42:48 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|