forked from premiere/premiere-libtorrent
merged RC_1_1 into master
This commit is contained in:
commit
1f9e74f40d
|
@ -91,6 +91,7 @@
|
||||||
* resume data no longer has timestamps of files
|
* resume data no longer has timestamps of files
|
||||||
* require C++11 to build libtorrent
|
* require C++11 to build libtorrent
|
||||||
|
|
||||||
|
* fix move_storage with save_path with a trailing slash
|
||||||
* fix tracker announce issue, advertising port 0 in secondary IPv6 announce
|
* fix tracker announce issue, advertising port 0 in secondary IPv6 announce
|
||||||
* fix missing boost/noncopyable.hpp includes
|
* fix missing boost/noncopyable.hpp includes
|
||||||
* fix python binding for torrent_info::creation_date()
|
* fix python binding for torrent_info::creation_date()
|
||||||
|
|
|
@ -148,7 +148,7 @@ namespace libtorrent {
|
||||||
TORRENT_EXTRA_EXPORT std::string remove_extension(std::string const& f);
|
TORRENT_EXTRA_EXPORT std::string remove_extension(std::string const& f);
|
||||||
TORRENT_EXTRA_EXPORT void replace_extension(std::string& f, std::string const& ext);
|
TORRENT_EXTRA_EXPORT void replace_extension(std::string& f, std::string const& ext);
|
||||||
TORRENT_EXTRA_EXPORT bool is_root_path(std::string const& f);
|
TORRENT_EXTRA_EXPORT bool is_root_path(std::string const& f);
|
||||||
|
TORRENT_EXTRA_EXPORT bool compare_path(std::string const& lhs, std::string const& rhs);
|
||||||
|
|
||||||
// internal used by create_torrent.hpp
|
// internal used by create_torrent.hpp
|
||||||
TORRENT_EXTRA_EXPORT std::string parent_path(std::string const& f);
|
TORRENT_EXTRA_EXPORT std::string parent_path(std::string const& f);
|
||||||
|
|
18
src/path.cpp
18
src/path.cpp
|
@ -596,6 +596,24 @@ namespace {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool compare_path(std::string const& lhs, std::string const& rhs)
|
||||||
|
{
|
||||||
|
std::string::size_type const lhs_size = !lhs.empty()
|
||||||
|
&& (lhs[lhs.size()-1] == '/'
|
||||||
|
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|
||||||
|
|| lhs[lhs.size()-1] == '\\'
|
||||||
|
#endif
|
||||||
|
) ? lhs.size() - 1 : lhs.size();
|
||||||
|
|
||||||
|
std::string::size_type const rhs_size = !rhs.empty()
|
||||||
|
&& (rhs[rhs.size()-1] == '/'
|
||||||
|
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|
||||||
|
|| rhs[rhs.size()-1] == '\\'
|
||||||
|
#endif
|
||||||
|
) ? rhs.size() - 1 : rhs.size();
|
||||||
|
return lhs.compare(0, lhs_size, rhs, 0, rhs_size) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool has_parent_path(std::string const& f)
|
bool has_parent_path(std::string const& f)
|
||||||
{
|
{
|
||||||
if (f.empty()) return false;
|
if (f.empty()) return false;
|
||||||
|
|
|
@ -382,7 +382,7 @@ namespace libtorrent { namespace aux {
|
||||||
error_code err;
|
error_code err;
|
||||||
std::string subdir = combine_path(save_path, s);
|
std::string subdir = combine_path(save_path, s);
|
||||||
|
|
||||||
while (subdir != save_path && !err)
|
while (!compare_path(subdir, save_path) && !err)
|
||||||
{
|
{
|
||||||
remove(subdir, err);
|
remove(subdir, err);
|
||||||
subdir = parent_path(subdir);
|
subdir = parent_path(subdir);
|
||||||
|
|
|
@ -205,6 +205,30 @@ TORRENT_TEST(paths)
|
||||||
TEST_EQUAL(is_root_path("/"), true);
|
TEST_EQUAL(is_root_path("/"), true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef TORRENT_WINDOWS
|
||||||
|
TEST_CHECK(compare_path("c:\\blah\\", "c:\\blah"));
|
||||||
|
TEST_CHECK(compare_path("c:\\blah", "c:\\blah"));
|
||||||
|
TEST_CHECK(compare_path("c:\\blah/", "c:\\blah"));
|
||||||
|
TEST_CHECK(compare_path("c:\\blah", "c:\\blah\\"));
|
||||||
|
TEST_CHECK(compare_path("c:\\blah", "c:\\blah"));
|
||||||
|
TEST_CHECK(compare_path("c:\\blah", "c:\\blah/"));
|
||||||
|
|
||||||
|
TEST_CHECK(!compare_path("c:\\bla", "c:\\blah/"));
|
||||||
|
TEST_CHECK(!compare_path("c:\\bla", "c:\\blah"));
|
||||||
|
TEST_CHECK(!compare_path("c:\\blah", "c:\\bla"));
|
||||||
|
TEST_CHECK(!compare_path("c:\\blah\\sdf", "c:\\blah"));
|
||||||
|
#else
|
||||||
|
TEST_CHECK(compare_path("/blah", "/blah"));
|
||||||
|
TEST_CHECK(compare_path("/blah/", "/blah"));
|
||||||
|
TEST_CHECK(compare_path("/blah", "/blah"));
|
||||||
|
TEST_CHECK(compare_path("/blah", "/blah/"));
|
||||||
|
|
||||||
|
TEST_CHECK(!compare_path("/bla", "/blah/"));
|
||||||
|
TEST_CHECK(!compare_path("/bla", "/blah"));
|
||||||
|
TEST_CHECK(!compare_path("/blah", "/bla"));
|
||||||
|
TEST_CHECK(!compare_path("/blah/sdf", "/blah"));
|
||||||
|
#endif
|
||||||
|
|
||||||
// if has_parent_path() returns false
|
// if has_parent_path() returns false
|
||||||
// parent_path() should return the empty string
|
// parent_path() should return the empty string
|
||||||
TEST_EQUAL(parent_path("blah"), "");
|
TEST_EQUAL(parent_path("blah"), "");
|
||||||
|
|
Loading…
Reference in New Issue