From 76ef0babed3770bdb8fe713c1308175eba7b663c Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 4 May 2017 09:22:17 -0400 Subject: [PATCH] remove deprecated file_base feature of file_storage --- ChangeLog | 1 + bindings/python/src/torrent_info.cpp | 3 -- include/libtorrent/file_storage.hpp | 29 --------------- src/file_storage.cpp | 54 ++-------------------------- src/storage.cpp | 18 ++-------- 5 files changed, 5 insertions(+), 100 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a6ace613..bcfb3f7f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * removed deprecated support for file_base in file_storage * added support for running separate DHT nodes on each network interface * added support for establishing UTP connections on any network interface * added support for sending tracker announces on every network interface diff --git a/bindings/python/src/torrent_info.cpp b/bindings/python/src/torrent_info.cpp index 89dfef174..80cf6b4f8 100644 --- a/bindings/python/src/torrent_info.cpp +++ b/bindings/python/src/torrent_info.cpp @@ -168,8 +168,6 @@ namespace bool get_send_stats(announce_entry const& ae) { return ae.send_stats; } std::int64_t get_size(file_entry const& fe) { return fe.size; } std::int64_t get_offset(file_entry const& fe) { return fe.offset; } - std::int64_t get_file_base(file_entry const& fe) { return fe.file_base; } - void set_file_base(file_entry& fe, int b) { fe.file_base = b; } bool get_pad_file(file_entry const& fe) { return fe.pad_file; } bool get_executable_attribute(file_entry const& fe) { return fe.executable_attribute; } bool get_hidden_attribute(file_entry const& fe) { return fe.hidden_attribute; } @@ -329,7 +327,6 @@ void bind_torrent_info() .add_property("symlink_attribute", &get_symlink_attribute) .add_property("offset", &get_offset) .add_property("size", &get_size) - .add_property("file_base", &get_file_base, &set_file_base) ; #endif diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index 5e9a3bd94..ffea1f41c 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -75,14 +75,6 @@ namespace libtorrent { // before it in the list. std::int64_t size; - // the offset in the file where the storage should start. The normal - // case is to have this set to 0, so that the storage starts saving data at the start - // if the file. In cases where multiple files are mapped into the same file though, - // the ``file_base`` should be set to an offset so that the different regions do - // not overlap. This is used when mapping "unselected" files into a so-called part - // file. - std::int64_t file_base; - // the modification time of this file specified in posix time. std::time_t mtime; @@ -420,9 +412,6 @@ namespace libtorrent { swap(ti.m_file_hashes, m_file_hashes); swap(ti.m_symlinks, m_symlinks); swap(ti.m_mtime, m_mtime); -#ifndef TORRENT_NO_DEPRECATE - swap(ti.m_file_base, m_file_base); -#endif swap(ti.m_paths, m_paths); swap(ti.m_name, m_name); swap(ti.m_total_size, m_total_size); @@ -532,13 +521,6 @@ namespace libtorrent { int file_name_len(file_index_t index) const; #ifndef TORRENT_NO_DEPRECATE - // deprecated in 1.1 - std::int64_t file_base_deprecated(int index) const; - TORRENT_DEPRECATED - std::int64_t file_base(int index) const; - TORRENT_DEPRECATED - void set_file_base(int index, std::int64_t off); - // these were deprecated in 1.0. Use the versions that take an index instead TORRENT_DEPRECATED sha1_hash hash(internal_file_entry const& fe) const; @@ -549,10 +531,6 @@ namespace libtorrent { TORRENT_DEPRECATED int file_index(internal_file_entry const& fe) const; TORRENT_DEPRECATED - std::int64_t file_base(internal_file_entry const& fe) const; - TORRENT_DEPRECATED - void set_file_base(internal_file_entry const& fe, std::int64_t off); - TORRENT_DEPRECATED std::string file_path(internal_file_entry const& fe, std::string const& save_path = "") const; TORRENT_DEPRECATED std::string file_name(internal_file_entry const& fe) const; @@ -611,13 +589,6 @@ namespace libtorrent { // index in m_files aux::vector m_mtime; -#ifndef TORRENT_NO_DEPRECATE - // if any file has a non-zero file base (i.e. multiple - // files residing in the same physical file at different - // offsets) - aux::vector m_file_base; -#endif - // all unique paths files have. The internal_file_entry::path_index // points into this array. The paths don't include the root directory // name for multi-file torrents. The m_name field need to be diff --git a/src/file_storage.cpp b/src/file_storage.cpp index b550b50fd..fbecd416e 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -180,7 +180,7 @@ namespace { } #ifndef TORRENT_NO_DEPRECATE - file_entry::file_entry(): offset(0), size(0), file_base(0) + file_entry::file_entry(): offset(0), size(0) , mtime(0), pad_file(false), hidden_attribute(false) , executable_attribute(false) , symlink_attribute(false) @@ -461,11 +461,7 @@ namespace { { file_slice f; f.file_index = file_index_t(int(file_iter - m_files.begin())); - f.offset = file_offset -#ifndef TORRENT_NO_DEPRECATE - + file_base_deprecated(f.file_index) -#endif - ; + f.offset = file_offset; f.size = std::min(std::int64_t(file_iter->size) - file_offset, std::int64_t(size)); TORRENT_ASSERT(f.size <= size); size -= int(f.size); @@ -492,7 +488,6 @@ namespace { ret.path = file_path(index); ret.offset = ife.offset; ret.size = ife.size; - ret.file_base = file_base(index); ret.mtime = mtime(index); ret.pad_file = ife.pad_file; ret.hidden_attribute = ife.hidden_attribute; @@ -831,25 +826,6 @@ namespace { } #ifndef TORRENT_NO_DEPRECATE - void file_storage::set_file_base(int index, std::int64_t off) - { - TORRENT_ASSERT_PRECOND(index >= file_index_t(0) && index < end_file()); - if (int(m_file_base.size()) <= index) m_file_base.resize(index + 1, 0); - m_file_base[index] = off; - } - - std::int64_t file_storage::file_base_deprecated(int index) const - { - if (index >= int(m_file_base.size())) return 0; - return m_file_base[index]; - } - - std::int64_t file_storage::file_base(int index) const - { - if (index >= int(m_file_base.size())) return 0; - return m_file_base[index]; - } - sha1_hash file_storage::hash(internal_file_entry const& fe) const { int index = int(&fe - &m_files[0]); @@ -877,21 +853,6 @@ namespace { return index; } - void file_storage::set_file_base(internal_file_entry const& fe, std::int64_t off) - { - int index = int(&fe - &m_files[0]); - TORRENT_ASSERT_PRECOND(index >= 0 && index < int(m_files.size())); - if (int(m_file_base.size()) <= index) m_file_base.resize(index + 1, 0); - m_file_base[index] = off; - } - - std::int64_t file_storage::file_base(internal_file_entry const& fe) const - { - int index = int(&fe - &m_files[0]); - if (index >= int(m_file_base.size())) return 0; - return m_file_base[index]; - } - std::string file_storage::file_path(internal_file_entry const& fe , std::string const& save_path) const { @@ -942,14 +903,6 @@ namespace { if (int(m_file_hashes.size()) < index) m_file_hashes.resize(index + 1, nullptr); std::iter_swap(m_file_hashes.begin() + dst, m_file_hashes.begin() + index); } -#ifndef TORRENT_NO_DEPRECATE - if (!m_file_base.empty()) - { - TORRENT_ASSERT(m_file_base.size() == m_files.size()); - if (int(m_file_base.size()) < index) m_file_base.resize(index + 1, 0); - std::iter_swap(m_file_base.begin() + dst, m_file_base.begin() + index); - } -#endif // TORRENT_DEPRECATED } void file_storage::optimize(int const pad_file_limit, int alignment @@ -1098,9 +1051,6 @@ namespace { if (!m_mtime.empty()) m_mtime.resize(index + 1, 0); if (!m_file_hashes.empty()) m_file_hashes.resize(index + 1, nullptr); -#ifndef TORRENT_NO_DEPRECATE - if (!m_file_base.empty()) m_file_base.resize(index + 1, 0); -#endif if (index != cur_index) reorder_file(index, cur_index); } diff --git a/src/storage.cpp b/src/storage.cpp index 8b8c4d213..9e407420b 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -506,15 +506,8 @@ namespace libtorrent { , file::read_only | flags, ec); if (ec) return -1; - // please ignore the adjusted_offset. It's just file_offset. - std::int64_t const adjusted_offset = -#ifndef TORRENT_NO_DEPRECATE - files().file_base_deprecated(file_index) + -#endif - file_offset; - error_code e; - int const ret = int(handle->readv(adjusted_offset + int const ret = int(handle->readv(file_offset , vec, e, flags)); // set this unconditionally in case the upper layer would like to treat @@ -580,15 +573,8 @@ namespace libtorrent { , file::read_write, ec); if (ec) return -1; - // please ignore the adjusted_offset. It's just file_offset. - std::int64_t const adjusted_offset = -#ifndef TORRENT_NO_DEPRECATE - files().file_base_deprecated(file_index) + -#endif - file_offset; - error_code e; - int const ret = int(handle->writev(adjusted_offset + int const ret = int(handle->writev(file_offset , vec, e, flags)); // set this unconditionally in case the upper layer would like to treat