fixed error handling in torrent_info constructor

This commit is contained in:
Arvid Norberg
2011-01-19 10:07:51 +00:00
parent 99d2c4eea8
commit 6663f527da
10 changed files with 33 additions and 24 deletions

View File

@@ -611,7 +611,7 @@ void add_torrent(libtorrent::session& ses
std::string filename = combine_path(save_path, t->name() + ".resume");
std::vector<char> buf;
if (load_file(filename.c_str(), buf) == 0)
if (load_file(filename.c_str(), buf, ec) == 0)
p.resume_data = &buf;
p.ti = t;
@@ -889,10 +889,10 @@ int main(int argc, char* argv[])
+ alert::stats_notification));
std::vector<char> in;
if (load_file(".ses_state", in) == 0)
error_code ec;
if (load_file(".ses_state", in, ec) == 0)
{
lazy_entry e;
error_code ec;
if (lazy_bdecode(&in[0], &in[0] + in.size(), e, ec) == 0)
ses.load_state(e);
}

View File

@@ -59,14 +59,14 @@ int main(int argc, char* argv[])
return 1;
}
std::vector<char> buf(size);
int ret = load_file(argv[1], buf, 40 * 1000000);
error_code ec;
int ret = load_file(argv[1], buf, ec, 40 * 1000000);
if (ret != 0)
{
fprintf(stderr, "failed to load file: %d\n", ret);
fprintf(stderr, "failed to load file: %s\n", ec.message().c_str());
return 1;
}
lazy_entry e;
error_code ec;
int pos;
printf("decoding. recursion limit: %d total item count limit: %d\n"
, depth_limit, item_limit);

View File

@@ -78,10 +78,10 @@ int main(int argc, char* argv[])
ses.set_settings(sett);
std::vector<char> in;
if (load_file(".ses_state", in) == 0)
error_code ec;
if (load_file(".ses_state", in, ec) == 0)
{
lazy_entry e;
error_code ec;
if (lazy_bdecode(&in[0], &in[0] + in.size(), e, ec) == 0)
ses.load_state(e);
}