*** empty log message ***
This commit is contained in:
parent
40bb52e464
commit
62bfb69863
|
@ -501,7 +501,7 @@ public:
|
|||
torrent_info(const entry& torrent_file)
|
||||
torrent_info(int piece_size, const char* name);
|
||||
|
||||
entry create_torrent(const char* created_by = 0) const;
|
||||
entry create_torrent() const;
|
||||
void set_comment(char const* str);
|
||||
void set_creator(char const* str);
|
||||
void set_hash(int index, const sha1_hash& h);
|
||||
|
|
|
@ -482,7 +482,7 @@ The ``torrent_info`` has the following synopsis::
|
|||
torrent_info(const entry& torrent_file)
|
||||
torrent_info(int piece_size, const char* name);
|
||||
|
||||
entry create_torrent(const char* created_by = 0) const;
|
||||
entry create_torrent() const;
|
||||
void set_comment(char const* str);
|
||||
void set_creator(char const* str);
|
||||
void set_hash(int index, const sha1_hash& h);
|
||||
|
|
|
@ -102,6 +102,7 @@ namespace libtorrent
|
|||
};
|
||||
}
|
||||
|
||||
class entry;
|
||||
|
||||
class entry
|
||||
{
|
||||
|
@ -171,13 +172,14 @@ namespace libtorrent
|
|||
|
||||
data_type m_type;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1300
|
||||
// workaround for msvc-bug.
|
||||
// assumes sizeof(map<string, char>) == sizeof(map<string, entry>)
|
||||
// and sizeof(list<char>) == sizeof(list<entry>)
|
||||
union
|
||||
{
|
||||
char data[detail::max4<sizeof(list_type)
|
||||
char data[
|
||||
detail::max4<sizeof(std::list<char>)
|
||||
, sizeof(std::map<std::string, char>)
|
||||
, sizeof(string_type)
|
||||
, sizeof(integer_type)>::value];
|
||||
|
|
|
@ -38,10 +38,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1300
|
||||
#define for if (false) {} else for
|
||||
#else
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
#endif
|
||||
|
||||
namespace libtorrent
|
||||
|
@ -252,6 +253,68 @@ namespace libtorrent
|
|||
, res);
|
||||
}
|
||||
*/
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1300
|
||||
|
||||
namespace detail
|
||||
{
|
||||
struct iterator_wrapper
|
||||
{
|
||||
typedef std::map<sha1_hash, boost::shared_ptr<torrent> >::iterator orig_iter;
|
||||
|
||||
orig_iter iter;
|
||||
|
||||
iterator_wrapper(orig_iter i): iter(i) {}
|
||||
void operator++() { ++iter; }
|
||||
torrent& operator*() { return *(iter->second); }
|
||||
bool operator==(const iterator_wrapper& i) const
|
||||
{ return iter == i.iter; }
|
||||
bool operator!=(const iterator_wrapper& i) const
|
||||
{ return iter != i.iter; }
|
||||
};
|
||||
|
||||
struct iterator_wrapper2
|
||||
{
|
||||
typedef std::map<address, peer_connection*>::iterator orig_iter;
|
||||
|
||||
orig_iter iter;
|
||||
|
||||
iterator_wrapper2(orig_iter i): iter(i) {}
|
||||
void operator++() { ++iter; }
|
||||
peer_connection& operator*() { return *(iter->second); }
|
||||
bool operator==(const iterator_wrapper2& i) const
|
||||
{ return iter == i.iter; }
|
||||
bool operator!=(const iterator_wrapper2& i) const
|
||||
{ return iter != i.iter; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void allocate_resources(
|
||||
int resources
|
||||
, std::map<sha1_hash, boost::shared_ptr<torrent> >& c
|
||||
, resource_request torrent::* res)
|
||||
{
|
||||
allocate_resources_impl(
|
||||
resources
|
||||
, detail::iterator_wrapper(c.begin())
|
||||
, detail::iterator_wrapper(c.end())
|
||||
, res);
|
||||
}
|
||||
|
||||
void allocate_resources(
|
||||
int resources
|
||||
, std::map<address, peer_connection*>& c
|
||||
, resource_request peer_connection::* res)
|
||||
{
|
||||
allocate_resources_impl(
|
||||
resources
|
||||
, detail::iterator_wrapper2(c.begin())
|
||||
, detail::iterator_wrapper2(c.end())
|
||||
, res);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void allocate_resources(
|
||||
int resources
|
||||
, std::map<sha1_hash, boost::shared_ptr<torrent> >& c
|
||||
|
@ -283,5 +346,6 @@ namespace libtorrent
|
|||
, new_iter(c.end(), &pick_peer2)
|
||||
, res);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace libtorrent
|
||||
|
|
|
@ -44,8 +44,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/invariant_check.hpp"
|
||||
#include "libtorrent/io.hpp"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1300
|
||||
#define for if (false) {} else for
|
||||
namespace std
|
||||
{
|
||||
using ::isprint;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define VERBOSE
|
||||
|
|
|
@ -872,6 +872,8 @@ namespace libtorrent
|
|||
, const boost::filesystem::path& save_path
|
||||
, const entry& resume_data)
|
||||
{
|
||||
if (ti.begin_files() == ti.end_files())
|
||||
throw std::runtime_error("no files in torrent");
|
||||
|
||||
{
|
||||
// lock the session
|
||||
|
|
|
@ -75,6 +75,64 @@ namespace libtorrent
|
|||
|
||||
namespace
|
||||
{
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1300
|
||||
|
||||
template<class T>
|
||||
struct transform_void{ typedef T type; };
|
||||
|
||||
template<>
|
||||
struct transform_void<void> { typedef int type; };
|
||||
|
||||
template<class Ret>
|
||||
struct void_call_wrapper
|
||||
{
|
||||
template<class F>
|
||||
static Ret call(F f, torrent& t)
|
||||
{
|
||||
return f(t);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct void_call_wrapper<void>
|
||||
{
|
||||
template<class F>
|
||||
static int call(F f, torrent& t)
|
||||
{
|
||||
f(t);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Ret, class F>
|
||||
transform_void<Ret>::type call_member(
|
||||
detail::session_impl* ses
|
||||
, detail::checker_impl* chk
|
||||
, sha1_hash const& hash
|
||||
, F f)
|
||||
{
|
||||
typedef typename transform_void<Ret>::type ret;
|
||||
if (ses == 0) throw invalid_handle();
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock l(ses->m_mutex);
|
||||
torrent* t = ses->find_torrent(hash);
|
||||
if (t != 0) return void_call_wrapper<Ret>::call(f, *t);
|
||||
}
|
||||
|
||||
|
||||
if (chk)
|
||||
{
|
||||
boost::mutex::scoped_lock l(chk->m_mutex);
|
||||
|
||||
detail::piece_checker_data* d = chk->find_torrent(hash);
|
||||
if (d != 0) return void_call_wrapper<Ret>::call(f, *d->torrent_ptr);
|
||||
}
|
||||
throw invalid_handle();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class Ret, class F>
|
||||
Ret call_member(
|
||||
detail::session_impl* ses
|
||||
|
@ -100,6 +158,8 @@ namespace libtorrent
|
|||
}
|
||||
throw invalid_handle();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
|
Loading…
Reference in New Issue