forked from premiere/premiere-libtorrent
added wpath overload for torrent_info constructor
This commit is contained in:
parent
a00ddba109
commit
58a3f6e4a0
|
@ -1222,6 +1222,7 @@ The ``torrent_info`` has the following synopsis::
|
|||
torrent_info(lazy_entry const& torrent_file);
|
||||
torrent_info(char const* buffer, int size);
|
||||
torrent_info(boost::filesystem::path const& filename);
|
||||
torrent_info(boost::filesystem::wpath const& filename);
|
||||
|
||||
void add_tracker(std::string const& url, int tier = 0);
|
||||
std::vector<announce_entry> const& trackers() const;
|
||||
|
@ -1280,6 +1281,7 @@ torrent_info()
|
|||
torrent_info(lazy_entry const& torrent_file);
|
||||
torrent_info(char const* buffer, int size);
|
||||
torrent_info(boost::filesystem::path const& filename);
|
||||
torrent_info(boost::filesystem::wpath const& filename);
|
||||
|
||||
The constructor that takes an info-hash will initialize the info-hash to the given value,
|
||||
but leave all other fields empty. This is used internally when downloading torrents without
|
||||
|
|
|
@ -171,6 +171,7 @@ namespace libtorrent
|
|||
torrent_info(lazy_entry const& torrent_file);
|
||||
torrent_info(char const* buffer, int size);
|
||||
torrent_info(fs::path const& filename);
|
||||
torrent_info(fs::wpath const& filename);
|
||||
~torrent_info();
|
||||
|
||||
file_storage const& files() const { return m_files; }
|
||||
|
|
|
@ -58,6 +58,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/hasher.hpp"
|
||||
#include "libtorrent/entry.hpp"
|
||||
#include "libtorrent/file.hpp"
|
||||
#include "libtorrent/utf8.hpp"
|
||||
|
||||
namespace gr = boost::gregorian;
|
||||
|
||||
|
@ -359,6 +360,35 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
torrent_info::torrent_info(fs::wpath const& filename)
|
||||
: m_creation_date(pt::ptime(pt::not_a_date_time))
|
||||
, m_multifile(false)
|
||||
, m_private(false)
|
||||
{
|
||||
std::vector<char> buf;
|
||||
std::string utf8;
|
||||
wchar_utf8(filename.string(), utf8);
|
||||
int ret = load_file(utf8, buf);
|
||||
if (ret < 0) return;
|
||||
|
||||
if (buf.empty())
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
throw invalid_torrent_file();
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
||||
lazy_entry e;
|
||||
lazy_bdecode(&buf[0], &buf[0] + buf.size(), e);
|
||||
std::string error;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if (!parse_torrent_file(e, error))
|
||||
throw invalid_torrent_file();
|
||||
#else
|
||||
parse_torrent_file(e, error);
|
||||
#endif
|
||||
}
|
||||
|
||||
torrent_info::~torrent_info()
|
||||
{}
|
||||
|
||||
|
|
Loading…
Reference in New Issue