improve hack in file_storage::symlink
This commit is contained in:
parent
ff113a262c
commit
ffd4b39b09
|
@ -45,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <set>
|
||||
#include <atomic>
|
||||
|
||||
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|
||||
#define TORRENT_SEPARATOR '\\'
|
||||
|
@ -663,7 +664,9 @@ namespace {
|
|||
|
||||
// TODO: 3 this is a hack to retain ABI compatibility with 1.2.1
|
||||
// in next major release, make this return by value
|
||||
static std::string ret;
|
||||
static std::string storage[4];
|
||||
static std::atomic<size_t> counter{0};
|
||||
std::string& ret = storage[(counter++) % 4];
|
||||
ret.reserve(m_name.size() + link.size() + 1);
|
||||
ret.assign(m_name);
|
||||
append_path(ret, link);
|
||||
|
|
|
@ -753,6 +753,28 @@ TORRENT_TEST(sanitize_symlinks_circular)
|
|||
TEST_EQUAL(fs.symlink(file_index_t{2}), "test" SEP "2");
|
||||
}
|
||||
|
||||
TORRENT_TEST(query_symlinks)
|
||||
{
|
||||
file_storage fs;
|
||||
fs.set_piece_length(1024);
|
||||
fs.add_file("test/0", 0, file_storage::flag_symlink, 0, "0");
|
||||
fs.add_file("test/1", 0, file_storage::flag_symlink, 0, "1");
|
||||
fs.add_file("test/2", 0, file_storage::flag_symlink, 0, "2");
|
||||
fs.add_file("test/3", 0, file_storage::flag_symlink, 0, "3");
|
||||
|
||||
auto const& ret1 = fs.symlink(file_index_t{0});
|
||||
auto const& ret2 = fs.symlink(file_index_t{1});
|
||||
auto const& ret3 = fs.symlink(file_index_t{2});
|
||||
auto const& ret4 = fs.symlink(file_index_t{3});
|
||||
|
||||
TEST_CHECK(ret1 != ret2);
|
||||
TEST_CHECK(ret1 != ret3);
|
||||
TEST_CHECK(ret1 != ret4);
|
||||
TEST_CHECK(ret2 != ret3);
|
||||
TEST_CHECK(ret2 != ret4);
|
||||
TEST_CHECK(ret3 != ret4);
|
||||
}
|
||||
|
||||
// TODO: test file attributes
|
||||
// TODO: test symlinks
|
||||
// TODO: test reorder_file (make sure internal_file_entry::swap() is used)
|
||||
|
|
Loading…
Reference in New Issue