forked from premiere/premiere-libtorrent
added character-set build feature (only effective on windows). Made storage build with win32/unicode and newer versions of boost. optimized allocate_slots
This commit is contained in:
parent
4c8e8470cd
commit
88d6f7a4c9
6
Jamfile
6
Jamfile
|
@ -21,19 +21,19 @@ use-project /boost : $(BOOST_ROOT) ;
|
||||||
|
|
||||||
|
|
||||||
feature logging : none default verbose : composite propagated symmetric link-incompatible ;
|
feature logging : none default verbose : composite propagated symmetric link-incompatible ;
|
||||||
feature.compose <logging>none : ;
|
|
||||||
feature.compose <logging>default : <define>TORRENT_LOGGING ;
|
feature.compose <logging>default : <define>TORRENT_LOGGING ;
|
||||||
feature.compose <logging>verbose : <define>TORRENT_VERBOSE_LOGGING ;
|
feature.compose <logging>verbose : <define>TORRENT_VERBOSE_LOGGING ;
|
||||||
|
|
||||||
feature dht-support : on off logging : composite propagated symmetric link-incompatible ;
|
feature dht-support : on off logging : composite propagated symmetric link-incompatible ;
|
||||||
feature.compose <dht-support>on : ;
|
|
||||||
feature.compose <dht-support>off : <define>TORRENT_DISABLE_DHT ;
|
feature.compose <dht-support>off : <define>TORRENT_DISABLE_DHT ;
|
||||||
feature.compose <dht-support>logging : <define>TORRENT_DHT_VERBOSE_LOGGING ;
|
feature.compose <dht-support>logging : <define>TORRENT_DHT_VERBOSE_LOGGING ;
|
||||||
|
|
||||||
feature openssl : off on : composite propagated symmetric link-incompatible ;
|
feature openssl : off on : composite propagated symmetric link-incompatible ;
|
||||||
feature.compose <openssl>off : ;
|
|
||||||
feature.compose <openssl>on : <define>TORRENT_USE_OPENSSL ;
|
feature.compose <openssl>on : <define>TORRENT_USE_OPENSSL ;
|
||||||
|
|
||||||
|
feature character-set : ansi unicode : composite propagated link-incompatible ;
|
||||||
|
feature.compose <character-set>unicode : <define>_UNICODE <define>UNICODE ;
|
||||||
|
|
||||||
SOURCES =
|
SOURCES =
|
||||||
allocate_resources
|
allocate_resources
|
||||||
alert
|
alert
|
||||||
|
|
|
@ -226,6 +226,21 @@ Build features:
|
||||||
| | * ``profile`` - builds libtorrent with profile |
|
| | * ``profile`` - builds libtorrent with profile |
|
||||||
| | information. |
|
| | information. |
|
||||||
+------------------------+----------------------------------------------------+
|
+------------------------+----------------------------------------------------+
|
||||||
|
| ``openssl`` | * ``on`` - openssl will be used instead of the |
|
||||||
|
| | public domain SHA-1 implementation shipped with |
|
||||||
|
| | libtorrent. ``crypto.lib`` or ``libcrypto.a`` |
|
||||||
|
| | will be required for linking. |
|
||||||
|
| | * ``off`` - the shipped SHA-1 implementation will |
|
||||||
|
| | be used, and there will be no dependency on |
|
||||||
|
| | openssl. |
|
||||||
|
+------------------------+----------------------------------------------------+
|
||||||
|
| ``character-set`` | This setting will only have an affect on windows. |
|
||||||
|
| | Other platforms are expected to support UTF-8. |
|
||||||
|
| | * ``ansi`` - The ansi version of the win32 API is |
|
||||||
|
| | used. |
|
||||||
|
| | * ``unicode`` - The unicode version of the win32 |
|
||||||
|
| | API is used. |
|
||||||
|
+------------------------+----------------------------------------------------+
|
||||||
|
|
||||||
The ``variant`` feature is *implicit*, which means you don't need to specify
|
The ``variant`` feature is *implicit*, which means you don't need to specify
|
||||||
the name of the feature, just the value.
|
the name of the feature, just the value.
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace libtorrent
|
||||||
bool verify_resume_data(entry& rd, std::string& error);
|
bool verify_resume_data(entry& rd, std::string& error);
|
||||||
|
|
||||||
bool is_allocating() const;
|
bool is_allocating() const;
|
||||||
bool allocate_slots(int num_slots);
|
bool allocate_slots(int num_slots, bool abort_on_disk = false);
|
||||||
void mark_failed(int index);
|
void mark_failed(int index);
|
||||||
|
|
||||||
unsigned long piece_crc(
|
unsigned long piece_crc(
|
||||||
|
|
|
@ -169,14 +169,13 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (new_handle == INVALID_HANDLE_VALUE)
|
if (new_handle == INVALID_HANDLE_VALUE)
|
||||||
{
|
|
||||||
std::stringstream s;
|
|
||||||
throw_exception(file_name);
|
throw_exception(file_name);
|
||||||
}
|
|
||||||
// try to make the file sparse if supported
|
// try to make the file sparse if supported
|
||||||
DWORD temp;
|
DWORD temp;
|
||||||
::DeviceIoControl(new_handle, FSCTL_SET_SPARSE, 0, 0
|
int ret = ::DeviceIoControl(new_handle, FSCTL_SET_SPARSE, 0, 0
|
||||||
, 0, 0, &temp, 0);
|
, 0, 0, &temp, 0);
|
||||||
|
if (ret == 0)
|
||||||
|
throw_exception(file_name);
|
||||||
// will only close old file if the open succeeded
|
// will only close old file if the open succeeded
|
||||||
close();
|
close();
|
||||||
m_file_handle = new_handle;
|
m_file_handle = new_handle;
|
||||||
|
|
|
@ -118,7 +118,9 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION < 13400
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using libtorrent::safe_convert;
|
using libtorrent::safe_convert;
|
||||||
|
@ -254,7 +256,7 @@ namespace libtorrent
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
path f = p / i->path;
|
path f = p / i->path;
|
||||||
#if defined(_WIN32) && defined(UNICODE)
|
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION < 13400
|
||||||
size = file_size_win(f);
|
size = file_size_win(f);
|
||||||
time = last_write_time_win(f);
|
time = last_write_time_win(f);
|
||||||
#else
|
#else
|
||||||
|
@ -291,7 +293,7 @@ namespace libtorrent
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
path f = p / i->path;
|
path f = p / i->path;
|
||||||
#if defined(_WIN32) && defined(UNICODE)
|
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION < 13400
|
||||||
size = file_size_win(f);
|
size = file_size_win(f);
|
||||||
time = last_write_time_win(f);
|
time = last_write_time_win(f);
|
||||||
#else
|
#else
|
||||||
|
@ -462,7 +464,7 @@ namespace libtorrent
|
||||||
|
|
||||||
save_path = complete(save_path);
|
save_path = complete(save_path);
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(UNICODE)
|
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION < 13400
|
||||||
std::wstring wsave_path(safe_convert(save_path.native_file_string()));
|
std::wstring wsave_path(safe_convert(save_path.native_file_string()));
|
||||||
if (!exists_win(save_path))
|
if (!exists_win(save_path))
|
||||||
{
|
{
|
||||||
|
@ -486,7 +488,7 @@ namespace libtorrent
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && defined(UNICODE)
|
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION < 13400
|
||||||
rename_win(old_path, new_path);
|
rename_win(old_path, new_path);
|
||||||
#else
|
#else
|
||||||
rename(old_path, new_path);
|
rename(old_path, new_path);
|
||||||
|
@ -876,7 +878,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void release_files();
|
void release_files();
|
||||||
|
|
||||||
bool allocate_slots(int num_slots);
|
bool allocate_slots(int num_slots, bool abort_on_disk = false);
|
||||||
void mark_failed(int index);
|
void mark_failed(int index);
|
||||||
unsigned long piece_crc(
|
unsigned long piece_crc(
|
||||||
int slot_index
|
int slot_index
|
||||||
|
@ -1499,13 +1501,20 @@ namespace libtorrent
|
||||||
// final position.
|
// final position.
|
||||||
assert(!m_unallocated_slots.empty());
|
assert(!m_unallocated_slots.empty());
|
||||||
|
|
||||||
|
if (!m_fill_mode)
|
||||||
|
{
|
||||||
// if we're not filling the allocation
|
// if we're not filling the allocation
|
||||||
// just make sure we move the current pieces
|
// just make sure we move the current pieces
|
||||||
// into place, and just skip all other
|
// into place, and just skip all other
|
||||||
// allocation
|
// allocation
|
||||||
// allocate_slots returns true if it had to
|
// allocate_slots returns true if it had to
|
||||||
// move any data
|
// move any data
|
||||||
while (!m_unallocated_slots.empty() && !allocate_slots(1));
|
allocate_slots(m_unallocated_slots.size(), true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
allocate_slots(1);
|
||||||
|
}
|
||||||
|
|
||||||
return std::make_pair(false, 1.f - (float)m_unallocated_slots.size()
|
return std::make_pair(false, 1.f - (float)m_unallocated_slots.size()
|
||||||
/ (float)m_slot_to_piece.size());
|
/ (float)m_slot_to_piece.size());
|
||||||
|
@ -1529,7 +1538,7 @@ namespace libtorrent
|
||||||
if (dir == last_path) continue;
|
if (dir == last_path) continue;
|
||||||
last_path = dir;
|
last_path = dir;
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(UNICODE)
|
#if defined(_WIN32) && defined(UNICODE) && BOOST_VERSION < 13400
|
||||||
if (!exists_win(last_path))
|
if (!exists_win(last_path))
|
||||||
create_directories_win(last_path);
|
create_directories_win(last_path);
|
||||||
#else
|
#else
|
||||||
|
@ -1997,7 +2006,7 @@ namespace libtorrent
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool piece_manager::impl::allocate_slots(int num_slots)
|
bool piece_manager::impl::allocate_slots(int num_slots, bool abort_on_disk)
|
||||||
{
|
{
|
||||||
assert(num_slots > 0);
|
assert(num_slots > 0);
|
||||||
|
|
||||||
|
@ -2034,6 +2043,7 @@ namespace libtorrent
|
||||||
assert(m_piece_to_slot[pos] >= 0);
|
assert(m_piece_to_slot[pos] >= 0);
|
||||||
m_storage->read(&buffer[0], m_piece_to_slot[pos], 0
|
m_storage->read(&buffer[0], m_piece_to_slot[pos], 0
|
||||||
, static_cast<int>(m_info.piece_size(pos)));
|
, static_cast<int>(m_info.piece_size(pos)));
|
||||||
|
std::cerr << "reading" << std::endl;
|
||||||
new_free_slot = m_piece_to_slot[pos];
|
new_free_slot = m_piece_to_slot[pos];
|
||||||
m_slot_to_piece[pos] = pos;
|
m_slot_to_piece[pos] = pos;
|
||||||
m_piece_to_slot[pos] = pos;
|
m_piece_to_slot[pos] = pos;
|
||||||
|
@ -2045,8 +2055,10 @@ namespace libtorrent
|
||||||
|
|
||||||
if (write_back || m_fill_mode)
|
if (write_back || m_fill_mode)
|
||||||
{
|
{
|
||||||
|
std::cerr << "writing" << std::endl;
|
||||||
m_storage->write(&buffer[0], pos, 0, static_cast<int>(m_info.piece_size(pos)));
|
m_storage->write(&buffer[0], pos, 0, static_cast<int>(m_info.piece_size(pos)));
|
||||||
written = true;
|
written = true;
|
||||||
|
if (abort_on_disk) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2054,9 +2066,9 @@ namespace libtorrent
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool piece_manager::allocate_slots(int num_slots)
|
bool piece_manager::allocate_slots(int num_slots, bool abort_on_disk)
|
||||||
{
|
{
|
||||||
return m_pimpl->allocate_slots(num_slots);
|
return m_pimpl->allocate_slots(num_slots, abort_on_disk);
|
||||||
}
|
}
|
||||||
|
|
||||||
path const& piece_manager::save_path() const
|
path const& piece_manager::save_path() const
|
||||||
|
|
Loading…
Reference in New Issue