deprecate file_base feature in file_storage/torrent_info
This commit is contained in:
parent
d49e97afb3
commit
c4a294e88a
|
@ -1,3 +1,4 @@
|
|||
* deprecate file_base feature in file_storage/torrent_info
|
||||
* improve piece picker support for reverse picking (used for snubbed peers)
|
||||
to not cause priority inversion for regular peers
|
||||
* improve piece picker to better support torrents with very large pieces
|
||||
|
|
|
@ -402,7 +402,9 @@ 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);
|
||||
|
@ -496,16 +498,6 @@ namespace libtorrent
|
|||
// to file at ``index``.
|
||||
int file_flags(int index) const;
|
||||
|
||||
// The file base of a file is the offset within the file on the filsystem
|
||||
// where it starts to write. For the most part, this is 0. It's possible
|
||||
// to map several files (in the torrent) into a single file on the
|
||||
// filesystem by making them all point to the same filename, but with
|
||||
// different file bases, so that they don't overlap.
|
||||
// torrent_info::remap_files() can be used to use a new file layout.
|
||||
// TODO: 3 deprecate the file_base feature
|
||||
boost::int64_t file_base(int index) const;
|
||||
void set_file_base(int index, boost::int64_t off);
|
||||
|
||||
// returns the index of the file at the given offset in the torrent
|
||||
int file_index_at_offset(boost::int64_t offset) const;
|
||||
|
||||
|
@ -516,6 +508,12 @@ namespace libtorrent
|
|||
int file_name_len(int index) const;
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
// deprecated in 1.1
|
||||
TORRENT_DEPRECATED_PREFIX
|
||||
boost::int64_t file_base(int index) const TORRENT_DEPRECATED;
|
||||
TORRENT_DEPRECATED_PREFIX
|
||||
void set_file_base(int index, boost::int64_t off) TORRENT_DEPRECATED;
|
||||
|
||||
// these were deprecated in 1.0. Use the versions that take an index instead
|
||||
TORRENT_DEPRECATED_PREFIX
|
||||
sha1_hash hash(internal_file_entry const& fe) const TORRENT_DEPRECATED;
|
||||
|
@ -583,10 +581,12 @@ namespace libtorrent
|
|||
// index in m_files
|
||||
std::vector<time_t> 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)
|
||||
std::vector<boost::int64_t> 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
|
||||
|
|
|
@ -398,7 +398,11 @@ namespace libtorrent
|
|||
{
|
||||
file_slice f;
|
||||
f.file_index = file_iter - m_files.begin();
|
||||
f.offset = file_offset + file_base(f.file_index);
|
||||
f.offset = file_offset
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
+ file_base(f.file_index)
|
||||
#endif
|
||||
;
|
||||
f.size = (std::min)(boost::uint64_t(file_iter->size) - file_offset, boost::uint64_t(size));
|
||||
TORRENT_ASSERT(f.size <= size);
|
||||
size -= int(f.size);
|
||||
|
@ -563,19 +567,6 @@ namespace libtorrent
|
|||
return m_mtime[index];
|
||||
}
|
||||
|
||||
void file_storage::set_file_base(int index, boost::int64_t off)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
boost::int64_t file_storage::file_base(int index) const
|
||||
{
|
||||
if (index >= int(m_file_base.size())) return 0;
|
||||
return m_file_base[index];
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
template <class CRC>
|
||||
|
@ -731,6 +722,19 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
void file_storage::set_file_base(int index, boost::int64_t off)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
boost::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 = &fe - &m_files[0];
|
||||
|
@ -826,12 +830,14 @@ namespace libtorrent
|
|||
if (int(m_file_hashes.size()) < index) m_file_hashes.resize(index + 1, NULL);
|
||||
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 pad_file_limit, int alignment)
|
||||
|
@ -930,7 +936,9 @@ namespace libtorrent
|
|||
|
||||
if (!m_mtime.empty()) m_mtime.resize(index + 1, 0);
|
||||
if (!m_file_hashes.empty()) m_file_hashes.resize(index + 1, NULL);
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
if (!m_file_base.empty()) m_file_base.resize(index + 1, 0);
|
||||
#endif
|
||||
|
||||
reorder_file(index, cur_index);
|
||||
|
||||
|
@ -949,7 +957,9 @@ namespace libtorrent
|
|||
std::vector<char const*>().swap(m_file_hashes);
|
||||
std::vector<std::string>().swap(m_symlinks);
|
||||
std::vector<time_t>().swap(m_mtime);
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
std::vector<boost::int64_t>().swap(m_file_base);
|
||||
#endif
|
||||
std::vector<std::string>().swap(m_paths);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1192,7 +1192,11 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
boost::int64_t adjusted_offset = files().file_base(file_index) + file_offset;
|
||||
boost::int64_t adjusted_offset =
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
files().file_base(file_index) +
|
||||
#endif
|
||||
file_offset;
|
||||
|
||||
#ifdef TORRENT_DISK_STATS
|
||||
int flags = ((op.mode & file::rw_mask) == file::read_only) ? op_read : op_write;
|
||||
|
|
Loading…
Reference in New Issue