improved support for platforms with no wchar_t and std::wstring
This commit is contained in:
parent
c6017f9366
commit
982cf7f7f7
|
@ -281,13 +281,16 @@ namespace libtorrent
|
|||
int as_for_ip(address const& a);
|
||||
std::pair<const int, int>* lookup_as(int as);
|
||||
bool load_asnum_db(char const* file);
|
||||
bool load_asnum_db(wchar_t const* file);
|
||||
bool has_asnum_db() const { return m_asnum_db; }
|
||||
|
||||
bool load_country_db(char const* file);
|
||||
bool load_country_db(wchar_t const* file);
|
||||
bool has_country_db() const { return m_country_db; }
|
||||
char const* country_for_ip(address const& a);
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
bool load_asnum_db(wchar_t const* file);
|
||||
bool load_country_db(wchar_t const* file);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void load_state(entry const& ses_state);
|
||||
|
|
|
@ -97,9 +97,13 @@ namespace libtorrent
|
|||
|
||||
void add_file(file_entry const& e);
|
||||
void add_file(fs::path const& p, size_type size, int flags = 0);
|
||||
void add_file(fs::wpath const& p, size_type size, int flags = 0);
|
||||
void rename_file(int index, std::string const& new_filename);
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
void add_file(fs::wpath const& p, size_type size, int flags = 0);
|
||||
void rename_file(int index, std::wstring const& new_filename);
|
||||
void set_name(std::wstring const& n);
|
||||
#endif
|
||||
|
||||
std::vector<file_slice> map_block(int piece, size_type offset
|
||||
, int size) const;
|
||||
|
@ -130,7 +134,6 @@ namespace libtorrent
|
|||
int piece_size(int index) const;
|
||||
|
||||
void set_name(std::string const& n) { m_name = n; }
|
||||
void set_name(std::wstring const& n);
|
||||
const std::string& name() const { TORRENT_ASSERT(m_piece_length > 0); return m_name; }
|
||||
|
||||
void swap(file_storage& ti)
|
||||
|
|
|
@ -296,9 +296,11 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_GEO_IP
|
||||
int as_for_ip(address const& addr);
|
||||
bool load_asnum_db(char const* file);
|
||||
bool load_asnum_db(wchar_t const* file);
|
||||
bool load_country_db(char const* file);
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
bool load_country_db(wchar_t const* file);
|
||||
bool load_asnum_db(wchar_t const* file);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void load_state(entry const& ses_state);
|
||||
|
|
|
@ -486,9 +486,12 @@ namespace libtorrent
|
|||
|
||||
// post condition: save_path() == save_path if true is returned
|
||||
void move_storage(fs::path const& save_path) const;
|
||||
void move_storage(fs::wpath const& save_path) const;
|
||||
void rename_file(int index, fs::path const& new_name) const;
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
void move_storage(fs::wpath const& save_path) const;
|
||||
void rename_file(int index, fs::wpath const& new_name) const;
|
||||
#endif
|
||||
|
||||
bool super_seeding() const;
|
||||
void super_seeding(bool on) const;
|
||||
|
|
|
@ -168,14 +168,18 @@ namespace libtorrent
|
|||
torrent_info(lazy_entry const& torrent_file);
|
||||
torrent_info(char const* buffer, int size);
|
||||
torrent_info(fs::path const& filename);
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
torrent_info(fs::wpath const& filename);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
torrent_info(sha1_hash const& info_hash);
|
||||
torrent_info(lazy_entry const& torrent_file, error_code& ec);
|
||||
torrent_info(char const* buffer, int size, error_code& ec);
|
||||
torrent_info(fs::path const& filename, error_code& ec);
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
torrent_info(fs::wpath const& filename, error_code& ec);
|
||||
#endif
|
||||
|
||||
~torrent_info();
|
||||
|
||||
|
@ -188,11 +192,13 @@ namespace libtorrent
|
|||
m_files.rename_file(index, new_filename);
|
||||
}
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
void rename_file(int index, std::wstring const& new_filename)
|
||||
{
|
||||
copy_on_write();
|
||||
m_files.rename_file(index, new_filename);
|
||||
}
|
||||
#endif
|
||||
|
||||
void add_tracker(std::string const& url, int tier = 0);
|
||||
std::vector<announce_entry> const& trackers() const { return m_urls; }
|
||||
|
|
|
@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef TORRENT_UTF8_HPP_INCLUDED
|
||||
#define TORRENT_UTF8_HPP_INCLUDED
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
|
||||
#include <string>
|
||||
#include <cwchar>
|
||||
#include "libtorrent/ConvertUTF.h"
|
||||
|
@ -97,8 +99,8 @@ namespace libtorrent
|
|||
return sourceIllegal;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace libtorrent
|
|||
return piece_length();
|
||||
}
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
void file_storage::set_name(std::wstring const& n)
|
||||
{
|
||||
std::string utf8;
|
||||
|
@ -67,12 +68,6 @@ namespace libtorrent
|
|||
m_name = utf8;
|
||||
}
|
||||
|
||||
void file_storage::rename_file(int index, std::string const& new_filename)
|
||||
{
|
||||
TORRENT_ASSERT(index >= 0 && index < int(m_files.size()));
|
||||
m_files[index].path = new_filename;
|
||||
}
|
||||
|
||||
void file_storage::rename_file(int index, std::wstring const& new_filename)
|
||||
{
|
||||
TORRENT_ASSERT(index >= 0 && index < int(m_files.size()));
|
||||
|
@ -81,6 +76,20 @@ namespace libtorrent
|
|||
m_files[index].path = utf8;
|
||||
}
|
||||
|
||||
void file_storage::add_file(fs::wpath const& file, size_type size, int flags)
|
||||
{
|
||||
std::string utf8;
|
||||
wchar_utf8(file.string(), utf8);
|
||||
add_file(utf8, size, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
void file_storage::rename_file(int index, std::string const& new_filename)
|
||||
{
|
||||
TORRENT_ASSERT(index >= 0 && index < int(m_files.size()));
|
||||
m_files[index].path = new_filename;
|
||||
}
|
||||
|
||||
file_storage::iterator file_storage::file_at_offset(size_type offset) const
|
||||
{
|
||||
// TODO: do a binary search
|
||||
|
@ -155,13 +164,6 @@ namespace libtorrent
|
|||
return ret;
|
||||
}
|
||||
|
||||
void file_storage::add_file(fs::wpath const& file, size_type size, int flags)
|
||||
{
|
||||
std::string utf8;
|
||||
wchar_utf8(file.string(), utf8);
|
||||
add_file(utf8, size, flags);
|
||||
}
|
||||
|
||||
void file_storage::add_file(fs::path const& file, size_type size, int flags)
|
||||
{
|
||||
TORRENT_ASSERT(size >= 0);
|
||||
|
|
|
@ -230,27 +230,28 @@ namespace libtorrent
|
|||
return m_impl->load_asnum_db(file);
|
||||
}
|
||||
|
||||
bool session::load_asnum_db(wchar_t const* file)
|
||||
{
|
||||
return m_impl->load_asnum_db(file);
|
||||
}
|
||||
|
||||
bool session::load_country_db(char const* file)
|
||||
{
|
||||
return m_impl->load_country_db(file);
|
||||
}
|
||||
|
||||
bool session::load_country_db(wchar_t const* file)
|
||||
{
|
||||
return m_impl->load_country_db(file);
|
||||
}
|
||||
|
||||
int session::as_for_ip(address const& addr)
|
||||
{
|
||||
aux::session_impl::mutex_t::scoped_lock l(m_impl->m_mutex);
|
||||
return m_impl->as_for_ip(addr);
|
||||
}
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
bool session::load_asnum_db(wchar_t const* file)
|
||||
{
|
||||
return m_impl->load_asnum_db(file);
|
||||
}
|
||||
|
||||
bool session::load_country_db(wchar_t const* file)
|
||||
{
|
||||
return m_impl->load_country_db(file);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void session::load_state(entry const& ses_state)
|
||||
|
|
|
@ -218,6 +218,7 @@ namespace libtorrent
|
|||
TORRENT_FORWARD(move_storage(save_path));
|
||||
}
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
void torrent_handle::move_storage(
|
||||
fs::wpath const& save_path) const
|
||||
{
|
||||
|
@ -227,12 +228,6 @@ namespace libtorrent
|
|||
TORRENT_FORWARD(move_storage(utf8));
|
||||
}
|
||||
|
||||
void torrent_handle::rename_file(int index, fs::path const& new_name) const
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_FORWARD(rename_file(index, new_name.string()));
|
||||
}
|
||||
|
||||
void torrent_handle::rename_file(int index, fs::wpath const& new_name) const
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
@ -240,6 +235,13 @@ namespace libtorrent
|
|||
wchar_utf8(new_name.string(), utf8);
|
||||
TORRENT_FORWARD(rename_file(index, utf8));
|
||||
}
|
||||
#endif
|
||||
|
||||
void torrent_handle::rename_file(int index, fs::path const& new_name) const
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_FORWARD(rename_file(index, new_name.string()));
|
||||
}
|
||||
|
||||
void torrent_handle::add_extension(
|
||||
boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> const& ext
|
||||
|
|
|
@ -386,6 +386,7 @@ namespace libtorrent
|
|||
throw invalid_torrent_file(ec);
|
||||
}
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
torrent_info::torrent_info(fs::wpath const& filename)
|
||||
: m_creation_date(pt::ptime(pt::not_a_date_time))
|
||||
, m_multifile(false)
|
||||
|
@ -409,6 +410,7 @@ namespace libtorrent
|
|||
if (!parse_torrent_file(e, ec))
|
||||
throw invalid_torrent_file(ec);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
torrent_info::torrent_info(lazy_entry const& torrent_file, error_code& ec)
|
||||
|
@ -458,6 +460,7 @@ namespace libtorrent
|
|||
parse_torrent_file(e, ec);
|
||||
}
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
torrent_info::torrent_info(fs::wpath const& filename, error_code& ec)
|
||||
: m_creation_date(pt::ptime(pt::not_a_date_time))
|
||||
, m_multifile(false)
|
||||
|
@ -479,6 +482,7 @@ namespace libtorrent
|
|||
}
|
||||
parse_torrent_file(e, ec);
|
||||
}
|
||||
#endif
|
||||
|
||||
// constructor used for creating new torrents
|
||||
// will not contain any hashes, comments, creation date
|
||||
|
|
Loading…
Reference in New Issue