From d0c2453f9efeab4d009391550f9313585a7fb8e9 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 25 Mar 2013 22:35:52 +0000 Subject: [PATCH] merge fix from RC_0_16 --- ChangeLog | 1 + src/torrent_info.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index cfbab8b94..378d1f746 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ * fix uTP edge case where udp socket buffer fills up * fix nagle implementation in uTP + * improve handling of filenames that are invalid on windows * support 'implied_port' in DHT announce_peer * don't use pool allocator for disk blocks (cache may now return pages to the kernel) diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 81ec99ead..b8ec0ca7a 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -214,6 +214,12 @@ namespace libtorrent path_element.resize(max_path_len - ext.size()); path_element += ext; } + // remove trailing spaces and dots. These aren't allowed in filenames on windows + for (int i = path_element.size() - 1; i >= 0; --i) + { + if (path_element[i] != L' ' && path_element[i] != L'.') break; + path_element[i] = L'_'; + } wchar_utf8(path_element, element); #else std::string& path_element = element;