diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index dbd8273ad..d5397fce2 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -281,13 +281,16 @@ namespace libtorrent int as_for_ip(address const& a); std::pair* 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); diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index 6473535e3..a69f9a198 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -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 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) diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index e8ecb6cd5..3916aeee4 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -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); diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 7a905e627..57fb50feb 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -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; diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index 16838888f..095e2bae5 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -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 const& trackers() const { return m_urls; } diff --git a/include/libtorrent/utf8.hpp b/include/libtorrent/utf8.hpp index 43805c40b..e74c3c292 100644 --- a/include/libtorrent/utf8.hpp +++ b/include/libtorrent/utf8.hpp @@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_UTF8_HPP_INCLUDED #define TORRENT_UTF8_HPP_INCLUDED +#ifndef BOOST_FILESYSTEM_NARROW_ONLY + #include #include #include "libtorrent/ConvertUTF.h" @@ -97,8 +99,8 @@ namespace libtorrent return sourceIllegal; } } - } +#endif #endif diff --git a/src/file_storage.cpp b/src/file_storage.cpp index 30de3bf22..bd0ba7ce8 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -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); diff --git a/src/session.cpp b/src/session.cpp index 219f1ede0..60b21f691 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -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) diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index dc5e6654b..c20495352 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -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(torrent*, void*)> const& ext diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 5bc45546a..8bf6ebb9f 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -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