fixed web seed for windows

This commit is contained in:
Arvid Norberg 2009-10-30 03:42:29 +00:00
parent 9d449caf84
commit c9392fe0fb
3 changed files with 19 additions and 0 deletions

View File

@ -75,6 +75,9 @@ namespace libtorrent
TORRENT_EXPORT boost::optional<std::string> url_has_argument(
std::string const& url, std::string argument);
// replaces \ with /
TORRENT_EXPORT void convert_path_to_posix(std::string& path);
TORRENT_EXPORT std::string read_until(char const*& str, char delim, char const* end);
TORRENT_EXPORT std::string to_hex(std::string const& s);
TORRENT_EXPORT bool is_hex(char const *in, int len);

View File

@ -264,6 +264,13 @@ namespace libtorrent
return false;
}
void convert_path_to_posix(std::string& path)
{
for (std::string::iterator i = path.begin()
, end(path.end()); i != end; ++i)
if (*i == '\\') *i = '/';
}
std::string read_until(char const*& str, char delim, char const* end)
{
TORRENT_ASSERT(str <= end);

View File

@ -261,12 +261,18 @@ namespace libtorrent
{
request += m_url;
std::string path = info.orig_files().at(f.file_index).path;
#ifdef TORRENT_WINDOWS
convert_path_to_posix(path);
#endif
request += escape_path(path.c_str(), path.length());
}
else
{
std::string path = m_path;
path += info.orig_files().at(f.file_index).path;
#ifdef TORRENT_WINDOWS
convert_path_to_posix(path);
#endif
request += escape_path(path.c_str(), path.length());
}
request += " HTTP/1.1\r\n";
@ -453,6 +459,9 @@ namespace libtorrent
torrent_info const& info = t->torrent_file();
std::string path = info.orig_files().at(file_index).path;
#ifdef TORRENT_WINDOWS
convert_path_to_posix(path);
#endif
path = escape_path(path.c_str(), path.length());
size_t i = location.rfind(path);
if (i == std::string::npos)