exception fixes

This commit is contained in:
Arvid Norberg 2009-04-07 15:06:07 +00:00
parent 970ab50e57
commit 981ae208d1
2 changed files with 12 additions and 4 deletions

View File

@ -158,8 +158,15 @@ int main(int argc, char* argv[])
, end(web_seeds.end()); i != end; ++i) , end(web_seeds.end()); i != end; ++i)
t.add_url_seed(*i); t.add_url_seed(*i);
error_code ec;
set_piece_hashes(t, full_path.branch_path() set_piece_hashes(t, full_path.branch_path()
, boost::bind(&print_progress, _1, t.num_pieces())); , boost::bind(&print_progress, _1, t.num_pieces()), ec);
if (ec)
{
std::cerr << ec.message() << std::endl;
return 1;
}
std::cerr << std::endl; std::cerr << std::endl;
t.set_creator(creator_str); t.set_creator(creator_str);

View File

@ -56,6 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/config.hpp>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)
@ -250,6 +251,7 @@ namespace libtorrent
} }
} }
#ifndef BOOST_NO_EXCEPTIONS
template <class Fun> template <class Fun>
void set_piece_hashes(create_torrent& t, boost::filesystem::path const& p, Fun f) void set_piece_hashes(create_torrent& t, boost::filesystem::path const& p, Fun f)
{ {
@ -258,19 +260,18 @@ namespace libtorrent
if (ec) throw libtorrent_exception(ec); if (ec) throw libtorrent_exception(ec);
} }
#ifndef BOOST_NOEXCEPTIONS
inline void set_piece_hashes(create_torrent& t, boost::filesystem::path const& p) inline void set_piece_hashes(create_torrent& t, boost::filesystem::path const& p)
{ {
error_code ec; error_code ec;
set_piece_hashes(t, p, detail::nop, ec); set_piece_hashes(t, p, detail::nop, ec);
if (ec) throw libtorrent_exception(ec); if (ec) throw libtorrent_exception(ec);
} }
#endif
inline void set_piece_hashes(create_torrent& t, boost::filesystem::path const& p, error_code& ec) inline void set_piece_hashes(create_torrent& t, boost::filesystem::path const& p, error_code& ec)
{ {
set_piece_hashes(t, p, detail::nop, ec); set_piece_hashes(t, p, detail::nop, ec);
} }
#endif
// wpath versions // wpath versions
@ -324,7 +325,7 @@ namespace libtorrent
} }
} }
#ifndef BOOST_NOEXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
template <class Fun> template <class Fun>
void set_piece_hashes(create_torrent& t, boost::filesystem::wpath const& p, Fun f) void set_piece_hashes(create_torrent& t, boost::filesystem::wpath const& p, Fun f)
{ {