forked from premiere/premiere-libtorrent
some compatibility fixes.
This commit is contained in:
parent
286c376f4e
commit
9d1989904b
1
Jamfile
1
Jamfile
|
@ -253,6 +253,7 @@ feature.compose <resolve-countries>off : <define>TORRENT_DISABLE_RESOLVE_COUNTRI
|
|||
|
||||
feature character-set : unicode ansi : composite propagated link-incompatible ;
|
||||
feature.compose <character-set>unicode : <define>_UNICODE <define>UNICODE ;
|
||||
feature.compose <character-set>ansi : <define>BOOST_FILESYSTEM_NARROW_ONLY=1 ;
|
||||
|
||||
feature zlib : shipped system : composite propagated link-incompatible ;
|
||||
|
||||
|
|
|
@ -30,11 +30,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <iomanip>
|
||||
|
||||
#include "libtorrent/entry.hpp"
|
||||
#include "libtorrent/bencode.hpp"
|
||||
#include "libtorrent/torrent_info.hpp"
|
||||
|
@ -45,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
using namespace boost::filesystem;
|
||||
|
@ -56,18 +50,18 @@ using namespace libtorrent;
|
|||
bool file_filter(boost::filesystem::path const& filename)
|
||||
{
|
||||
if (filename.leaf()[0] == '.') return false;
|
||||
std::cerr << filename << std::endl;
|
||||
fprintf(stderr, "%s\n", filename.string().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
void print_progress(int i, int num)
|
||||
{
|
||||
std::cerr << "\r" << (i+1) << "/" << num;
|
||||
fprintf(stderr, "\r%d/%d", i+1, num);
|
||||
}
|
||||
|
||||
void print_usage()
|
||||
{
|
||||
std::cerr << "usage: make_torrent FILE [OPTIONS]\n"
|
||||
fputs("usage: make_torrent FILE [OPTIONS]\n"
|
||||
"\n"
|
||||
"Generates a torrent file from the specified file\n"
|
||||
"or directory and writes it to standard out\n\n"
|
||||
|
@ -81,7 +75,8 @@ void print_usage()
|
|||
"-p bytes enables padding files. Files larger\n"
|
||||
" than bytes will be piece-aligned\n"
|
||||
"-s bytes specifies a piece size for the torrent\n"
|
||||
" This has to be a multiple of 16 kiB\n";
|
||||
" This has to be a multiple of 16 kiB\n"
|
||||
, stderr);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -163,20 +158,23 @@ int main(int argc, char* argv[])
|
|||
, boost::bind(&print_progress, _1, t.num_pieces()), ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cerr << ec.message() << std::endl;
|
||||
fprintf(stderr, "%s\n", ec.message().c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cerr << std::endl;
|
||||
fprintf(stderr, "\n");
|
||||
t.set_creator(creator_str);
|
||||
|
||||
// create the torrent and print it to stdout
|
||||
bencode(std::ostream_iterator<char>(std::cout), t.generate());
|
||||
std::vector<char> torrent;
|
||||
bencode(back_inserter(torrent), t.generate());
|
||||
fwrite(&torrent[0], 1, torrent.size(), stdout);
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << "\n";
|
||||
fprintf(stderr, "%s\n", e.what());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -82,12 +82,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/alert.hpp" // for alert_manager
|
||||
#include "libtorrent/deadline_timer.hpp"
|
||||
#include "libtorrent/socket_io.hpp" // for print_address
|
||||
#include "libtorrent/peer_connection.hpp" // for intrusive_ptr_release
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
class peer_connection;
|
||||
class upnp;
|
||||
class natpmp;
|
||||
class lsd;
|
||||
|
|
|
@ -54,7 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
|
@ -148,7 +148,9 @@ namespace libtorrent
|
|||
namespace detail
|
||||
{
|
||||
inline bool default_pred(boost::filesystem::path const&) { return true; }
|
||||
#if TORRENT_USE_WPATH
|
||||
inline bool wdefault_pred(boost::filesystem::wpath const&) { return true; }
|
||||
#endif
|
||||
|
||||
inline bool ignore_subdir(std::string const& leaf)
|
||||
{ return leaf == ".." || leaf == "."; }
|
||||
|
@ -159,13 +161,19 @@ namespace libtorrent
|
|||
inline void nop(int i) {}
|
||||
|
||||
int TORRENT_EXPORT get_file_attributes(boost::filesystem::path const& p);
|
||||
#if TORRENT_USE_WPATH
|
||||
int TORRENT_EXPORT get_file_attributes(boost::filesystem::wpath const& p);
|
||||
#endif
|
||||
|
||||
std::time_t TORRENT_EXPORT get_file_mtime(boost::filesystem::path const& p);
|
||||
#if TORRENT_USE_WPATH
|
||||
std::time_t TORRENT_EXPORT get_file_mtime(boost::filesystem::wpath const& p);
|
||||
#endif
|
||||
|
||||
fs::path TORRENT_EXPORT get_symlink_path(boost::filesystem::path const& p);
|
||||
#if TORRENT_USE_WPATH
|
||||
fs::path TORRENT_EXPORT get_symlink_path(boost::filesystem::wpath const& p);
|
||||
#endif
|
||||
|
||||
template <class Pred, class Str, class PathTraits>
|
||||
void add_files_impl(file_storage& fs, boost::filesystem::basic_path<Str, PathTraits> const& p
|
||||
|
@ -289,6 +297,7 @@ namespace libtorrent
|
|||
set_piece_hashes(t, p, detail::nop, ec);
|
||||
}
|
||||
|
||||
#if TORRENT_USE_WPATH
|
||||
// wpath versions
|
||||
|
||||
template <class Pred>
|
||||
|
@ -362,6 +371,9 @@ namespace libtorrent
|
|||
{
|
||||
set_piece_hashes(t, p, detail::nop, ec);
|
||||
}
|
||||
|
||||
#endif // TORRENT_USE_WPATH
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push, 1)
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace libtorrent
|
|||
int start;
|
||||
int length;
|
||||
bool operator==(peer_request const& r) const
|
||||
{ return piece == r.piece && start == r.start && length == r.length; }
|
||||
{ return piece == r.piece && start == r.start && length == r.length; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace libtorrent
|
|||
|
||||
struct TORRENT_EXPORT piece_block
|
||||
{
|
||||
piece_block() {}
|
||||
piece_block(int p_index, int b_index)
|
||||
: piece_index(p_index)
|
||||
, block_index(b_index)
|
||||
|
|
|
@ -36,13 +36,15 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <AvailabilityMacros.h>
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
#include <cxxabi.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <stdlib.h>
|
||||
|
||||
// uClibc++ doesn't have cxxabi.h
|
||||
#if defined __GNUC__ && !defined __UCLIBCXX_MAJOR__
|
||||
|
||||
#include <cxxabi.h>
|
||||
|
||||
std::string demangle(char const* name)
|
||||
{
|
||||
// in case this string comes
|
||||
|
@ -81,6 +83,8 @@ std::string demangle(char const* name)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
std::string demangle(char const* name) { return name; }
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -35,9 +35,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/storage.hpp"
|
||||
#include "libtorrent/escape_string.hpp"
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/date_time/gregorian/gregorian.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
#include <boost/date_time/gregorian/greg_date.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -81,6 +82,7 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
#if TORRENT_USE_WPATH
|
||||
int TORRENT_EXPORT get_file_attributes(boost::filesystem::wpath const& p)
|
||||
{
|
||||
#ifdef TORRENT_WINDOWS
|
||||
|
@ -103,6 +105,7 @@ namespace libtorrent
|
|||
return file_attr;
|
||||
#endif
|
||||
}
|
||||
#endif // TORRENT_USE_WPATH
|
||||
|
||||
std::time_t get_file_mtime(char const* path)
|
||||
{
|
||||
|
@ -129,6 +132,7 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
#if TORRENT_USE_WPATH
|
||||
std::time_t TORRENT_EXPORT get_file_mtime(boost::filesystem::wpath const& p)
|
||||
{
|
||||
#ifdef TORRENT_WINDOWS
|
||||
|
@ -142,6 +146,7 @@ namespace libtorrent
|
|||
return get_file_mtime(utf8.c_str());
|
||||
#endif
|
||||
}
|
||||
#endif // TORRENT_USE_WPATH
|
||||
|
||||
#ifndef TORRENT_WINDOWS
|
||||
boost::filesystem::path get_symlink_path_impl(char const* path)
|
||||
|
@ -165,6 +170,7 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
#if TORRENT_USE_WPATH
|
||||
boost::filesystem::path TORRENT_EXPORT get_symlink_path(boost::filesystem::wpath const& p)
|
||||
{
|
||||
#ifdef TORRENT_WINDOWS
|
||||
|
@ -176,6 +182,7 @@ namespace libtorrent
|
|||
return get_symlink_path_impl(utf8.c_str());
|
||||
#endif
|
||||
}
|
||||
#endif // TORRENT_USE_WPATH
|
||||
|
||||
}
|
||||
|
||||
|
@ -464,7 +471,7 @@ namespace libtorrent
|
|||
for (std::vector<sha1_hash>::const_iterator i = m_piece_hash.begin();
|
||||
i != m_piece_hash.end(); ++i)
|
||||
{
|
||||
p.append((char*)i->begin(), (char*)i->end());
|
||||
p.append((char*)i->begin(), sha1_hash::size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue