merged UNC path fixes from libtorrent_aio

This commit is contained in:
Arvid Norberg 2012-06-16 23:23:36 +00:00
parent 9e8488048e
commit 342a0b9306
2 changed files with 15 additions and 15 deletions

View File

@ -320,18 +320,18 @@ setup_transfer(session* ses1, session* ses2, session* ses3
if (torrent == 0) if (torrent == 0)
{ {
error_code ec; error_code ec;
create_directory("./tmp1" + suffix, ec); create_directory("tmp1" + suffix, ec);
std::ofstream file(("./tmp1" + suffix + "/temporary").c_str()); std::ofstream file(combine_path("tmp1" + suffix, "temporary").c_str());
t = ::create_torrent(&file, piece_size, 19, true, encrypted_torrent); t = ::create_torrent(&file, piece_size, 19, true, encrypted_torrent);
file.close(); file.close();
if (clear_files) if (clear_files)
{ {
remove_all("./tmp2" + suffix + "/temporary", ec); remove_all(combine_path("tmp2" + suffix, "temporary"), ec);
remove_all("./tmp3" + suffix + "/temporary", ec); remove_all(combine_path("tmp3" + suffix, "temporary"), ec);
} }
char ih_hex[41]; char ih_hex[41];
to_hex((char const*)&t->info_hash()[0], 20, ih_hex); to_hex((char const*)&t->info_hash()[0], 20, ih_hex);
fprintf(stderr, "generated torrent: %s ./tmp1%s/temporary\n", ih_hex, suffix.c_str()); fprintf(stderr, "generated torrent: %s tmp1%s/temporary\n", ih_hex, suffix.c_str());
} }
else else
{ {
@ -346,7 +346,7 @@ setup_transfer(session* ses1, session* ses2, session* ses3
param.flags &= ~add_torrent_params::flag_auto_managed; param.flags &= ~add_torrent_params::flag_auto_managed;
if (p) param = *p; if (p) param = *p;
param.ti = clone_ptr(t); param.ti = clone_ptr(t);
param.save_path = "./tmp1" + suffix; param.save_path = "tmp1" + suffix;
param.flags |= add_torrent_params::flag_seed_mode; param.flags |= add_torrent_params::flag_seed_mode;
error_code ec; error_code ec;
torrent_handle tor1 = ses1->add_torrent(param, ec); torrent_handle tor1 = ses1->add_torrent(param, ec);
@ -362,7 +362,7 @@ setup_transfer(session* ses1, session* ses2, session* ses3
if (ses3) if (ses3)
{ {
param.ti = clone_ptr(t); param.ti = clone_ptr(t);
param.save_path = "./tmp3" + suffix; param.save_path = "tmp3" + suffix;
tor3 = ses3->add_torrent(param, ec); tor3 = ses3->add_torrent(param, ec);
TEST_CHECK(!ses3->get_torrents().empty()); TEST_CHECK(!ses3->get_torrents().empty());
} }
@ -376,7 +376,7 @@ setup_transfer(session* ses1, session* ses2, session* ses3
{ {
param.ti = clone_ptr(t); param.ti = clone_ptr(t);
} }
param.save_path = "./tmp2" + suffix; param.save_path = "tmp2" + suffix;
tor2 = ses2->add_torrent(param, ec); tor2 = ses2->add_torrent(param, ec);
TEST_CHECK(!ses2->get_torrents().empty()); TEST_CHECK(!ses2->get_torrents().empty());
@ -1039,7 +1039,7 @@ void web_server_thread(int* port, bool ssl, bool chunked)
boost::uint64_t off = idx * 64 * 1024 + range_start; boost::uint64_t off = idx * 64 * 1024 + range_start;
std::vector<char> file_buf; std::vector<char> file_buf;
error_code ec; error_code ec;
int res = load_file("./tmp1_web_seed/seed", file_buf, ec); int res = load_file(combine_path("tmp1_web_seed", "seed"), file_buf, ec);
if (res == -1 || file_buf.empty()) if (res == -1 || file_buf.empty())
{ {

View File

@ -61,8 +61,8 @@ int test_main()
s->set_settings(sett); s->set_settings(sett);
error_code ec; error_code ec;
create_directory("./tmp1_tracker", ec); create_directory("tmp1_tracker", ec);
std::ofstream file("./tmp1_tracker/temporary"); std::ofstream file(combine_path("tmp1_tracker", "temporary").c_str());
boost::intrusive_ptr<torrent_info> t = ::create_torrent(&file, 16 * 1024, 13, false); boost::intrusive_ptr<torrent_info> t = ::create_torrent(&file, 16 * 1024, 13, false);
file.close(); file.close();
@ -77,7 +77,7 @@ int test_main()
addp.flags &= ~add_torrent_params::flag_paused; addp.flags &= ~add_torrent_params::flag_paused;
addp.flags &= ~add_torrent_params::flag_auto_managed; addp.flags &= ~add_torrent_params::flag_auto_managed;
addp.ti = t; addp.ti = t;
addp.save_path = "./tmp1_tracker"; addp.save_path = "tmp1_tracker";
torrent_handle h = s->add_torrent(addp); torrent_handle h = s->add_torrent(addp);
for (int i = 0; i < 100; ++i) for (int i = 0; i < 100; ++i)
@ -113,8 +113,8 @@ int test_main()
sett.tracker_receive_timeout = 1; sett.tracker_receive_timeout = 1;
s->set_settings(sett); s->set_settings(sett);
create_directory("./tmp2_tracker", ec); create_directory("tmp2_tracker", ec);
file.open("./tmp2_tracker/temporary"); file.open(combine_path("tmp2_tracker", "temporary").c_str());
t = ::create_torrent(&file, 16 * 1024, 13, false); t = ::create_torrent(&file, 16 * 1024, 13, false);
file.close(); file.close();
@ -142,7 +142,7 @@ int test_main()
addp.flags &= ~add_torrent_params::flag_paused; addp.flags &= ~add_torrent_params::flag_paused;
addp.flags &= ~add_torrent_params::flag_auto_managed; addp.flags &= ~add_torrent_params::flag_auto_managed;
addp.ti = t; addp.ti = t;
addp.save_path = "./tmp2_tracker"; addp.save_path = "tmp2_tracker";
h = s->add_torrent(addp); h = s->add_torrent(addp);
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)