forked from premiere/premiere-libtorrent
moved the error_category to error_code.cpp and added the new files (error_code.{hpp|.cpp}) to the Jamfile and makefiles
This commit is contained in:
parent
429a118dd2
commit
2ab80ddc3a
1
Jamfile
1
Jamfile
|
@ -287,6 +287,7 @@ SOURCES =
|
||||||
create_torrent
|
create_torrent
|
||||||
disk_buffer_holder
|
disk_buffer_holder
|
||||||
entry
|
entry
|
||||||
|
error_code
|
||||||
file_storage
|
file_storage
|
||||||
lazy_bdecode
|
lazy_bdecode
|
||||||
escape_string
|
escape_string
|
||||||
|
|
|
@ -17,6 +17,7 @@ libtorrent/disk_io_thread.hpp \
|
||||||
libtorrent/entry.hpp \
|
libtorrent/entry.hpp \
|
||||||
libtorrent/enum_net.hpp \
|
libtorrent/enum_net.hpp \
|
||||||
libtorrent/escape_string.hpp \
|
libtorrent/escape_string.hpp \
|
||||||
|
libtorrent/error_code.hpp \
|
||||||
libtorrent/extensions.hpp \
|
libtorrent/extensions.hpp \
|
||||||
libtorrent/file.hpp \
|
libtorrent/file.hpp \
|
||||||
libtorrent/file_pool.hpp \
|
libtorrent/file_pool.hpp \
|
||||||
|
|
|
@ -43,10 +43,31 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace errors
|
||||||
|
{
|
||||||
|
enum error_code_enum
|
||||||
|
{
|
||||||
|
no_error = 0,
|
||||||
|
file_collision
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#if BOOST_VERSION < 103500
|
#if BOOST_VERSION < 103500
|
||||||
typedef asio::error_code error_code;
|
typedef asio::error_code error_code;
|
||||||
inline asio::error::error_category get_posix_category() { return asio::error::system_category; }
|
inline asio::error::error_category get_posix_category() { return asio::error::system_category; }
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
struct libtorrent_error_category : boost::system::error_category
|
||||||
|
{
|
||||||
|
virtual const char* name() const;
|
||||||
|
virtual std::string message(int ev) const;
|
||||||
|
virtual boost::system::error_condition default_error_condition(int ev) const
|
||||||
|
{ return boost::system::error_condition(ev, *this); }
|
||||||
|
};
|
||||||
|
|
||||||
|
extern libtorrent_error_category libtorrent_category;
|
||||||
|
|
||||||
using boost::system::error_code;
|
using boost::system::error_code;
|
||||||
inline boost::system::error_category const& get_posix_category()
|
inline boost::system::error_category const& get_posix_category()
|
||||||
{ return boost::system::get_posix_category(); }
|
{ return boost::system::get_posix_category(); }
|
||||||
|
|
|
@ -24,7 +24,7 @@ logger.cpp file_pool.cpp ut_pex.cpp lsd.cpp upnp.cpp instantiate_connection.cpp
|
||||||
socks5_stream.cpp socks4_stream.cpp http_stream.cpp connection_queue.cpp \
|
socks5_stream.cpp socks4_stream.cpp http_stream.cpp connection_queue.cpp \
|
||||||
disk_io_thread.cpp ut_metadata.cpp magnet_uri.cpp udp_socket.cpp smart_ban.cpp \
|
disk_io_thread.cpp ut_metadata.cpp magnet_uri.cpp udp_socket.cpp smart_ban.cpp \
|
||||||
http_parser.cpp gzip.cpp disk_buffer_holder.cpp create_torrent.cpp GeoIP.c \
|
http_parser.cpp gzip.cpp disk_buffer_holder.cpp create_torrent.cpp GeoIP.c \
|
||||||
parse_url.cpp file_storage.cpp $(kademlia_sources)
|
parse_url.cpp file_storage.cpp error_code.cpp $(kademlia_sources)
|
||||||
# mapped_storage.cpp
|
# mapped_storage.cpp
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
|
@ -46,6 +46,7 @@ $(top_srcdir)/include/libtorrent/disk_io_thread.hpp \
|
||||||
$(top_srcdir)/include/libtorrent/entry.hpp \
|
$(top_srcdir)/include/libtorrent/entry.hpp \
|
||||||
$(top_srcdir)/include/libtorrent/enum_net.hpp \
|
$(top_srcdir)/include/libtorrent/enum_net.hpp \
|
||||||
$(top_srcdir)/include/libtorrent/escape_string.hpp \
|
$(top_srcdir)/include/libtorrent/escape_string.hpp \
|
||||||
|
$(top_srcdir)/include/libtorrent/error_code.hpp \
|
||||||
$(top_srcdir)/include/libtorrent/extensions.hpp \
|
$(top_srcdir)/include/libtorrent/extensions.hpp \
|
||||||
$(top_srcdir)/include/libtorrent/extensions/metadata_transfer.hpp \
|
$(top_srcdir)/include/libtorrent/extensions/metadata_transfer.hpp \
|
||||||
$(top_srcdir)/include/libtorrent/extensions/logger.hpp \
|
$(top_srcdir)/include/libtorrent/extensions/logger.hpp \
|
||||||
|
|
|
@ -42,36 +42,6 @@ namespace libtorrent
|
||||||
using boost::multi_index::nth_index;
|
using boost::multi_index::nth_index;
|
||||||
using boost::multi_index::get;
|
using boost::multi_index::get;
|
||||||
|
|
||||||
#if BOOST_VERSION >= 103500
|
|
||||||
struct file_pool_error_category : boost::system::error_category
|
|
||||||
{
|
|
||||||
virtual const char* name() const { return "file pool error"; }
|
|
||||||
virtual std::string message(int ev) const
|
|
||||||
{
|
|
||||||
static char const* msgs[] =
|
|
||||||
{ "no error", "torrent file collides with file from another torrent" };
|
|
||||||
if (ev < 0 || ev >= sizeof(msgs)/sizeof(msgs[0]))
|
|
||||||
return "Unknown error";
|
|
||||||
return msgs[ev];
|
|
||||||
}
|
|
||||||
virtual boost::system::error_condition default_error_condition(int ev) const
|
|
||||||
{
|
|
||||||
return boost::system::error_condition(ev, *this);
|
|
||||||
}
|
|
||||||
virtual bool equivalent(int code, boost::system::error_condition const& condition) const
|
|
||||||
{
|
|
||||||
return default_error_condition(code) == condition;
|
|
||||||
}
|
|
||||||
virtual bool equivalent(boost::system::error_code const& code, int condition ) const
|
|
||||||
{
|
|
||||||
return *this == code.category() && code.value() == condition;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
file_pool_error_category file_pool_category;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
boost::shared_ptr<file> file_pool::open_file(void* st, fs::path const& p
|
boost::shared_ptr<file> file_pool::open_file(void* st, fs::path const& p
|
||||||
, file::open_mode m, error_code& ec)
|
, file::open_mode m, error_code& ec)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +62,7 @@ namespace libtorrent
|
||||||
// this means that another instance of the storage
|
// this means that another instance of the storage
|
||||||
// is using the exact same file.
|
// is using the exact same file.
|
||||||
#if BOOST_VERSION >= 103500
|
#if BOOST_VERSION >= 103500
|
||||||
ec = error_code(1, file_pool_category);
|
ec = error_code(errors::file_collision, libtorrent_category);
|
||||||
#endif
|
#endif
|
||||||
return boost::shared_ptr<file>();
|
return boost::shared_ptr<file>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue