improved support for platforms with no wchar_t and std::wstring

This commit is contained in:
Arvid Norberg
2009-03-31 08:12:35 +00:00
parent c6017f9366
commit 982cf7f7f7
10 changed files with 64 additions and 36 deletions

View File

@@ -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);