forked from premiere/premiere-libtorrent
merged changes from RC_1_0
This commit is contained in:
parent
edfa38cd30
commit
3f61ee0ff3
|
@ -152,7 +152,6 @@ option(exceptions "build with exception support" ON)
|
|||
option(logging "build with logging" OFF)
|
||||
option(verbose-logging "build with verbose logging" OFF)
|
||||
option(build_tests "build tests" OFF)
|
||||
option(build_examples "build examples" ON)
|
||||
|
||||
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo)
|
||||
|
||||
|
@ -311,6 +310,10 @@ add_definitions(-D_FILE_OFFSET_BITS=64)
|
|||
add_definitions(-DBOOST_EXCEPTION_DISABLE)
|
||||
add_definitions(-DBOOST_ASIO_ENABLE_CANCELIO)
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
add_definitions(-fcolor-diagnostics)
|
||||
endif()
|
||||
|
||||
if (tcmalloc)
|
||||
target_link_libraries(torrent-rasterbar tcmalloc)
|
||||
endif()
|
||||
|
@ -342,16 +345,10 @@ install(DIRECTORY include/libtorrent
|
|||
PATTERN ".svn" EXCLUDE)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtorrent-rasterbar.pc DESTINATION ${LIBDIR}/pkgconfig)
|
||||
|
||||
# === build examples ===
|
||||
if(build_examples)
|
||||
# this will make some internal functions available in the
|
||||
# DLL interface, for the examples to access
|
||||
add_definitions(-DTORRENT_EXPORT_EXTRA)
|
||||
|
||||
# to build the examples, run cmake in this subdirectory
|
||||
# after libtorrent is built
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/examples)
|
||||
endif()
|
||||
# === set up examples directory as an independent project ===
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/examples)
|
||||
configure_file(examples/run_cmake.sh.in examples/run_cmake.sh)
|
||||
# to build the examples, run examples/run_cmake.sh after building libtorrent
|
||||
|
||||
# === build tests ===
|
||||
if(build_tests)
|
||||
|
|
|
@ -229,8 +229,7 @@ def main():
|
|||
if f.startswith('magnet:') or f.startswith('http://') or f.startswith('https://'):
|
||||
atp["url"] = f
|
||||
else:
|
||||
e = lt.bdecode(open(f, 'rb').read())
|
||||
info = lt.torrent_info(e)
|
||||
info = lt.torrent_info(f)
|
||||
print('Adding \'%s\'...' % info.name())
|
||||
|
||||
try:
|
||||
|
|
|
@ -1 +1 @@
|
|||
@COMPILETIME_OPTIONS@ @CPPFLAGS@ @LIBS@ @BOOST_SYSTEM_LIB@ @BOOST_PYTHON_LIB@ @PTHREAD_LIBS@ @OPENSSL_LIBS@ @OPENSSL_LDFLAGS@ @OPENSSL_INCLUDES@ -I@top_srcdir@/include
|
||||
@COMPILETIME_OPTIONS@ @CPPFLAGS@ @LIBS@ @BOOST_CPPFLAGS@ @BOOST_SYSTEM_LIB@ @BOOST_PYTHON_LIB@ @PTHREAD_LIBS@ @OPENSSL_LIBS@ @OPENSSL_LDFLAGS@ @OPENSSL_INCLUDES@ -I@top_srcdir@/include
|
||||
|
|
|
@ -1 +1 @@
|
|||
-L@top_builddir@/src/.libs @LDFLAGS@
|
||||
-L@top_builddir@/src/.libs @BOOST_LDFLAGS@ @LDFLAGS@
|
||||
|
|
|
@ -177,6 +177,26 @@ namespace
|
|||
|
||||
} // namespace unnamed
|
||||
|
||||
boost::intrusive_ptr<torrent_info> buffer_constructor(char const* buf, int len, int flags)
|
||||
{
|
||||
error_code ec;
|
||||
boost::intrusive_ptr<torrent_info> ret(new torrent_info(buf, len, ec, flags));
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (ec) throw libtorrent_exception(ec);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
boost::intrusive_ptr<torrent_info> file_constructor(std::string const& filename, int flags)
|
||||
{
|
||||
error_code ec;
|
||||
boost::intrusive_ptr<torrent_info> ret(new torrent_info(filename, ec, flags));
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (ec) throw libtorrent_exception(ec);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
void bind_torrent_info()
|
||||
{
|
||||
return_value_policy<copy_const_reference> copy;
|
||||
|
@ -196,10 +216,12 @@ void bind_torrent_info()
|
|||
#ifndef TORRENT_NO_DEPRECATE
|
||||
.def(init<entry const&>(arg("e")))
|
||||
#endif
|
||||
|
||||
.def(init<sha1_hash const&, int>((arg("info_hash"), arg("flags") = 0)))
|
||||
.def(init<char const*, int, int>((arg("buffer"), arg("length"), arg("flags") = 0)))
|
||||
.def(init<std::string, int>((arg("file"), arg("flags") = 0)))
|
||||
.def("__init__", make_constructor(&buffer_constructor))
|
||||
.def("__init__", make_constructor(&file_constructor))
|
||||
.def(init<torrent_info const&>((arg("ti"))))
|
||||
|
||||
#if TORRENT_USE_WSTRING && !defined TORRENT_NO_DEPRECATE
|
||||
.def(init<std::wstring, int>((arg("file"), arg("flags") = 0)))
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,7 @@ bin_PROGRAMS = $(example_programs)
|
|||
endif
|
||||
|
||||
EXTRA_PROGRAMS = $(example_programs)
|
||||
EXTRA_DIST = Jamfile CMakeLists.txt cmake/FindLibtorrentRasterbar.cmake
|
||||
EXTRA_DIST = Jamfile CMakeLists.txt run_cmake.sh.in cmake/FindLibtorrentRasterbar.cmake
|
||||
|
||||
client_test_SOURCES = client_test.cpp print.cpp session_view.cpp torrent_view.cpp
|
||||
#client_test_LDADD = $(top_builddir)/src/libtorrent-rasterbar.la
|
||||
|
|
|
@ -34,6 +34,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/config.hpp"
|
||||
|
||||
#ifdef TORRENT_WINDOWS
|
||||
#include <direct.h> // for _mkdir
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push, 1)
|
||||
#endif
|
||||
|
@ -634,8 +638,8 @@ std::vector<std::string> list_dir(std::string path
|
|||
{
|
||||
std::vector<std::string> ret;
|
||||
#ifdef TORRENT_WINDOWS
|
||||
if (!f.empty() && f[f.size()-1] != '\\') f += "\\*";
|
||||
else f += "*";
|
||||
if (!path.empty() && path[path.size()-1] != '\\') path += "\\*";
|
||||
else path += "*";
|
||||
|
||||
std::wstring wpath;
|
||||
libtorrent::utf8_wchar(path, wpath);
|
||||
|
@ -822,24 +826,36 @@ bool handle_alert(libtorrent::session& ses, libtorrent::alert* a
|
|||
if (torrent_need_cert_alert* p = alert_cast<torrent_need_cert_alert>(a))
|
||||
{
|
||||
torrent_handle h = p->handle;
|
||||
error_code ec;
|
||||
file_status st;
|
||||
std::string base_name = path_append("certificates", to_hex(h.info_hash().to_string()));
|
||||
std::string cert = base_name + ".pem";
|
||||
std::string priv = base_name + "_key.pem";
|
||||
stat_file(cert, &st, ec);
|
||||
if (ec)
|
||||
|
||||
#ifdef TORRENT_WINDOWS
|
||||
struct ::_stat st;
|
||||
int ret = ::_stat(cert.c_str(), &st);
|
||||
if (ret < 0 || (st.st_mode & _S_IFREG) == 0)
|
||||
#else
|
||||
struct ::stat st;
|
||||
int ret = ::stat(cert.c_str(), &st);
|
||||
if (ret < 0 || (st.st_mode & S_IFREG) == 0)
|
||||
#endif
|
||||
{
|
||||
char msg[256];
|
||||
snprintf(msg, sizeof(msg), "ERROR. could not load certificate %s: %s\n", cert.c_str(), ec.message().c_str());
|
||||
snprintf(msg, sizeof(msg), "ERROR. could not load certificate %s: %s\n", cert.c_str(), strerror(errno));
|
||||
if (g_log_file) fprintf(g_log_file, "[%s] %s\n", timestamp(), msg);
|
||||
return true;
|
||||
}
|
||||
stat_file(priv, &st, ec);
|
||||
if (ec)
|
||||
|
||||
#ifdef TORRENT_WINDOWS
|
||||
ret = ::_stat(priv.c_str(), &st);
|
||||
if (ret < 0 || (st.st_mode & _S_IFREG) == 0)
|
||||
#else
|
||||
ret = ::stat(priv.c_str(), &st);
|
||||
if (ret < 0 || (st.st_mode & S_IFREG) == 0)
|
||||
#endif
|
||||
{
|
||||
char msg[256];
|
||||
snprintf(msg, sizeof(msg), "ERROR. could not load private key %s: %s\n", priv.c_str(), ec.message().c_str());
|
||||
snprintf(msg, sizeof(msg), "ERROR. could not load private key %s: %s\n", priv.c_str(), strerror(errno));
|
||||
if (g_log_file) fprintf(g_log_file, "[%s] %s\n", timestamp(), msg);
|
||||
return true;
|
||||
}
|
||||
|
@ -1408,7 +1424,11 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
// create directory for resume files
|
||||
#ifdef TORRENT_WINDOWS
|
||||
int ret = _mkdir(path_append(save_path, ".resume").c_str());
|
||||
#else
|
||||
int ret = mkdir(path_append(save_path, ".resume").c_str(), 0777);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
fprintf(stderr, "failed to create resume file directory: (%d) %s\n"
|
||||
, errno, strerror(errno));
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd ${libtorrent_BINARY_DIR}/examples
|
||||
cmake \
|
||||
-D libtorrent_includes_asio_source=${asio_source} \
|
||||
-G "${CMAKE_GENERATOR}" \
|
||||
$@ \
|
||||
${libtorrent_SOURCE_DIR}/examples
|
|
@ -109,7 +109,11 @@ std::vector<char> generate_resume_data(torrent_info* ti)
|
|||
entry::list_type& httpseeds = rd["httpseeds"].list();
|
||||
httpseeds.push_back(entry("http://resume_data_http_seed.com"));
|
||||
|
||||
#ifdef TORRENT_WINDOWS
|
||||
rd["save_path"] = "c:\\resume_data save_path";
|
||||
#else
|
||||
rd["save_path"] = "/resume_data save_path";
|
||||
#endif
|
||||
|
||||
std::vector<char> ret;
|
||||
bencode(back_inserter(ret), rd);
|
||||
|
@ -127,7 +131,11 @@ torrent_status test_resume_flags(int flags)
|
|||
|
||||
p.ti = ti;
|
||||
p.flags = flags;
|
||||
#ifdef TORRENT_WINDOWS
|
||||
p.save_path = "c:\\add_torrent_params save_path";
|
||||
#else
|
||||
p.save_path = "/add_torrent_params save_path";
|
||||
#endif
|
||||
p.trackers.push_back("http://add_torrent_params_tracker.com/announce");
|
||||
p.url_seeds.push_back("http://add_torrent_params_url_seed.com");
|
||||
|
||||
|
@ -165,7 +173,11 @@ int test_main()
|
|||
fprintf(stderr, "flags: 0\n");
|
||||
s = test_resume_flags(0);
|
||||
default_tests(s);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_EQUAL(s.save_path, "c:\\add_torrent_params save_path");
|
||||
#else
|
||||
TEST_EQUAL(s.save_path, "/add_torrent_params save_path");
|
||||
#endif
|
||||
TEST_EQUAL(s.sequential_download, false);
|
||||
TEST_EQUAL(s.paused, false);
|
||||
TEST_EQUAL(s.auto_managed, false);
|
||||
|
@ -180,7 +192,11 @@ int test_main()
|
|||
fprintf(stderr, "flags: use_resume_save_path\n");
|
||||
s = test_resume_flags(add_torrent_params::flag_use_resume_save_path);
|
||||
default_tests(s);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_EQUAL(s.save_path, "c:\\resume_data save_path");
|
||||
#else
|
||||
TEST_EQUAL(s.save_path, "/resume_data save_path");
|
||||
#endif
|
||||
TEST_EQUAL(s.sequential_download, false);
|
||||
TEST_EQUAL(s.paused, false);
|
||||
TEST_EQUAL(s.auto_managed, false);
|
||||
|
@ -197,7 +213,11 @@ int test_main()
|
|||
| add_torrent_params::flag_paused);
|
||||
|
||||
default_tests(s);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_EQUAL(s.save_path, "c:\\add_torrent_params save_path");
|
||||
#else
|
||||
TEST_EQUAL(s.save_path, "/add_torrent_params save_path");
|
||||
#endif
|
||||
TEST_EQUAL(s.sequential_download, false);
|
||||
TEST_EQUAL(s.paused, true);
|
||||
TEST_EQUAL(s.auto_managed, false);
|
||||
|
@ -213,7 +233,11 @@ int test_main()
|
|||
s = test_resume_flags(add_torrent_params::flag_override_resume_data
|
||||
| add_torrent_params::flag_seed_mode);
|
||||
default_tests(s);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_EQUAL(s.save_path, "c:\\add_torrent_params save_path");
|
||||
#else
|
||||
TEST_EQUAL(s.save_path, "/add_torrent_params save_path");
|
||||
#endif
|
||||
TEST_EQUAL(s.sequential_download, false);
|
||||
TEST_EQUAL(s.paused, false);
|
||||
TEST_EQUAL(s.auto_managed, false);
|
||||
|
@ -228,7 +252,11 @@ int test_main()
|
|||
fprintf(stderr, "flags: upload_mode\n");
|
||||
s = test_resume_flags(add_torrent_params::flag_upload_mode);
|
||||
default_tests(s);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_EQUAL(s.save_path, "c:\\add_torrent_params save_path");
|
||||
#else
|
||||
TEST_EQUAL(s.save_path, "/add_torrent_params save_path");
|
||||
#endif
|
||||
TEST_EQUAL(s.sequential_download, false);
|
||||
TEST_EQUAL(s.paused, false);
|
||||
TEST_EQUAL(s.auto_managed, false);
|
||||
|
@ -244,7 +272,11 @@ int test_main()
|
|||
s = test_resume_flags(add_torrent_params::flag_override_resume_data
|
||||
| add_torrent_params::flag_share_mode);
|
||||
default_tests(s);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_EQUAL(s.save_path, "c:\\add_torrent_params save_path");
|
||||
#else
|
||||
TEST_EQUAL(s.save_path, "/add_torrent_params save_path");
|
||||
#endif
|
||||
TEST_EQUAL(s.sequential_download, false);
|
||||
TEST_EQUAL(s.paused, false);
|
||||
TEST_EQUAL(s.auto_managed, false);
|
||||
|
@ -260,7 +292,11 @@ int test_main()
|
|||
fprintf(stderr, "flags: auto_managed\n");
|
||||
s = test_resume_flags(add_torrent_params::flag_auto_managed);
|
||||
default_tests(s);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_EQUAL(s.save_path, "c:\\add_torrent_params save_path");
|
||||
#else
|
||||
TEST_EQUAL(s.save_path, "/add_torrent_params save_path");
|
||||
#endif
|
||||
TEST_EQUAL(s.sequential_download, false);
|
||||
TEST_EQUAL(s.paused, false);
|
||||
TEST_EQUAL(s.auto_managed, false);
|
||||
|
@ -276,7 +312,11 @@ int test_main()
|
|||
fprintf(stderr, "flags: paused\n");
|
||||
s = test_resume_flags(add_torrent_params::flag_paused);
|
||||
default_tests(s);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_EQUAL(s.save_path, "c:\\add_torrent_params save_path");
|
||||
#else
|
||||
TEST_EQUAL(s.save_path, "/add_torrent_params save_path");
|
||||
#endif
|
||||
TEST_EQUAL(s.sequential_download, false);
|
||||
TEST_EQUAL(s.paused, false);
|
||||
TEST_EQUAL(s.auto_managed, false);
|
||||
|
|
|
@ -439,12 +439,20 @@ int test_main()
|
|||
else if (std::string(test_torrents[i].file) == "slash_path.torrent")
|
||||
{
|
||||
TEST_EQUAL(ti->num_files(), 1);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_EQUAL(ti->file_at(0).path, "temp\\bar");
|
||||
#else
|
||||
TEST_EQUAL(ti->file_at(0).path, "temp/bar");
|
||||
#endif
|
||||
}
|
||||
else if (std::string(test_torrents[i].file) == "slash_path2.torrent")
|
||||
{
|
||||
TEST_EQUAL(ti->num_files(), 1);
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_EQUAL(ti->file_at(0).path, "temp\\abc....def\\bar");
|
||||
#else
|
||||
TEST_EQUAL(ti->file_at(0).path, "temp/abc....def/bar");
|
||||
#endif
|
||||
}
|
||||
else if (std::string(test_torrents[i].file) == "slash_path3.torrent")
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue