formatting, added std:: and spaces
This commit is contained in:
parent
dd7179fb10
commit
3a92908f39
|
@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
#include "libtorrent/storage_defs.hpp"
|
#include "libtorrent/storage_defs.hpp"
|
||||||
#include "libtorrent/sha1_hash.hpp"
|
#include "libtorrent/sha1_hash.hpp"
|
||||||
|
@ -381,14 +382,14 @@ namespace libtorrent
|
||||||
// was first added, including previous runs/sessions. If set to zero, the
|
// was first added, including previous runs/sessions. If set to zero, the
|
||||||
// internal added_time will be set to the time of when add_torrent() is
|
// internal added_time will be set to the time of when add_torrent() is
|
||||||
// called.
|
// called.
|
||||||
time_t added_time = 0;
|
std::time_t added_time = 0;
|
||||||
time_t completed_time = 0;
|
std::time_t completed_time = 0;
|
||||||
|
|
||||||
// if set to non-zero, initializes the time (expressed in posix time) when
|
// if set to non-zero, initializes the time (expressed in posix time) when
|
||||||
// we last saw a seed or peers that together formed a complete copy of the
|
// we last saw a seed or peers that together formed a complete copy of the
|
||||||
// torrent. If left set to zero, the internal counterpart to this field
|
// torrent. If left set to zero, the internal counterpart to this field
|
||||||
// will be updated when we see a seed or a distributed copies >= 1.0.
|
// will be updated when we see a seed or a distributed copies >= 1.0.
|
||||||
time_t last_seen_complete = 0;
|
std::time_t last_seen_complete = 0;
|
||||||
|
|
||||||
// these field can be used to initialize the torrent's cached scrape data.
|
// these field can be used to initialize the torrent's cached scrape data.
|
||||||
// The scrape data is high level metadata about the current state of the
|
// The scrape data is high level metadata about the current state of the
|
||||||
|
|
|
@ -462,7 +462,7 @@ namespace libtorrent
|
||||||
// index (given the piece size).
|
// index (given the piece size).
|
||||||
sha1_hash hash(int index) const;
|
sha1_hash hash(int index) const;
|
||||||
std::string const& symlink(int index) const;
|
std::string const& symlink(int index) const;
|
||||||
time_t mtime(int index) const;
|
std::time_t mtime(int index) const;
|
||||||
std::string file_path(int index, std::string const& save_path = "") const;
|
std::string file_path(int index, std::string const& save_path = "") const;
|
||||||
string_view file_name(int index) const;
|
string_view file_name(int index) const;
|
||||||
std::int64_t file_size(int index) const;
|
std::int64_t file_size(int index) const;
|
||||||
|
@ -538,7 +538,7 @@ namespace libtorrent
|
||||||
TORRENT_DEPRECATED
|
TORRENT_DEPRECATED
|
||||||
std::string const& symlink(internal_file_entry const& fe) const;
|
std::string const& symlink(internal_file_entry const& fe) const;
|
||||||
TORRENT_DEPRECATED
|
TORRENT_DEPRECATED
|
||||||
time_t mtime(internal_file_entry const& fe) const;
|
std::time_t mtime(internal_file_entry const& fe) const;
|
||||||
TORRENT_DEPRECATED
|
TORRENT_DEPRECATED
|
||||||
int file_index(internal_file_entry const& fe) const;
|
int file_index(internal_file_entry const& fe) const;
|
||||||
TORRENT_DEPRECATED
|
TORRENT_DEPRECATED
|
||||||
|
@ -602,7 +602,7 @@ namespace libtorrent
|
||||||
// is empty if no file have a modification time.
|
// is empty if no file have a modification time.
|
||||||
// each element corresponds to the file with the same
|
// each element corresponds to the file with the same
|
||||||
// index in m_files
|
// index in m_files
|
||||||
std::vector<time_t> m_mtime;
|
std::vector<std::time_t> m_mtime;
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// if any file has a non-zero file base (i.e. multiple
|
// if any file has a non-zero file base (i.e. multiple
|
||||||
|
|
|
@ -166,11 +166,11 @@ namespace libtorrent
|
||||||
#define PROT_READ PAGE_READONLY
|
#define PROT_READ PAGE_READONLY
|
||||||
#define PROT_WRITE PAGE_READWRITE
|
#define PROT_WRITE PAGE_READWRITE
|
||||||
#endif
|
#endif
|
||||||
const int page = page_size();
|
int const page = page_size();
|
||||||
// make the two surrounding pages non-readable and -writable
|
// make the two surrounding pages non-readable and -writable
|
||||||
mprotect(block - page, page, PROT_READ | PROT_WRITE);
|
mprotect(block - page, page, PROT_READ | PROT_WRITE);
|
||||||
alloc_header* h = reinterpret_cast<alloc_header*>(block - page);
|
alloc_header* h = reinterpret_cast<alloc_header*>(block - page);
|
||||||
const int num_pages = int((h->size + (page-1)) / page + 2);
|
int const num_pages = int((h->size + (page - 1)) / page + 2);
|
||||||
TORRENT_ASSERT(h->magic == 0x1337);
|
TORRENT_ASSERT(h->magic == 0x1337);
|
||||||
mprotect(block + (num_pages - 2) * page, page, PROT_READ | PROT_WRITE);
|
mprotect(block + (num_pages - 2) * page, page, PROT_READ | PROT_WRITE);
|
||||||
// std::fprintf(stderr, "free: %p head: %p tail: %p size: %d\n", block, block - page, block + h->size, int(h->size));
|
// std::fprintf(stderr, "free: %p head: %p tail: %p size: %d\n", block, block - page, block + h->size, int(h->size));
|
||||||
|
|
|
@ -294,7 +294,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(m_token_idx != -1);
|
TORRENT_ASSERT(m_token_idx != -1);
|
||||||
bdecode_token const& t = m_root_tokens[m_token_idx];
|
bdecode_token const& t = m_root_tokens[m_token_idx];
|
||||||
bdecode_token const& next = m_root_tokens[m_token_idx + t.next_item];
|
bdecode_token const& next = m_root_tokens[m_token_idx + t.next_item];
|
||||||
return { m_buffer + t.offset, size_t(next.offset - t.offset) };
|
return {m_buffer + t.offset, std::size_t(next.offset - t.offset)};
|
||||||
}
|
}
|
||||||
|
|
||||||
bdecode_node bdecode_node::list_at(int i) const
|
bdecode_node bdecode_node::list_at(int i) const
|
||||||
|
@ -574,7 +574,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(type() == string_t);
|
TORRENT_ASSERT(type() == string_t);
|
||||||
bdecode_token const& t = m_root_tokens[m_token_idx];
|
bdecode_token const& t = m_root_tokens[m_token_idx];
|
||||||
size_t const size = m_root_tokens[m_token_idx + 1].offset - t.offset - t.start_offset();
|
std::size_t const size = m_root_tokens[m_token_idx + 1].offset - t.offset - t.start_offset();
|
||||||
TORRENT_ASSERT(t.type == bdecode_token::string);
|
TORRENT_ASSERT(t.type == bdecode_token::string);
|
||||||
|
|
||||||
return string_view(m_buffer + t.offset + t.start_offset(), size);
|
return string_view(m_buffer + t.offset + t.start_offset(), size);
|
||||||
|
|
|
@ -1196,7 +1196,7 @@ namespace libtorrent
|
||||||
|
|
||||||
int const file_flags = file_flags_for_job(j
|
int const file_flags = file_flags_for_job(j
|
||||||
, m_settings.get_bool(settings_pack::coalesce_reads));
|
, m_settings.get_bool(settings_pack::coalesce_reads));
|
||||||
file::iovec_t b = { j->buffer.disk_block, size_t(j->d.io.buffer_size) };
|
file::iovec_t b = {j->buffer.disk_block, std::size_t(j->d.io.buffer_size)};
|
||||||
|
|
||||||
int ret = j->storage->readv(b
|
int ret = j->storage->readv(b
|
||||||
, j->piece, j->d.io.offset, file_flags, j->error);
|
, j->piece, j->d.io.offset, file_flags, j->error);
|
||||||
|
@ -1428,7 +1428,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
time_point const start_time = clock_type::now();
|
time_point const start_time = clock_type::now();
|
||||||
|
|
||||||
file::iovec_t const b = { j->buffer.disk_block, size_t(j->d.io.buffer_size) };
|
file::iovec_t const b = {j->buffer.disk_block, std::size_t(j->d.io.buffer_size)};
|
||||||
int const file_flags = file_flags_for_job(j
|
int const file_flags = file_flags_for_job(j
|
||||||
, m_settings.get_bool(settings_pack::coalesce_writes));
|
, m_settings.get_bool(settings_pack::coalesce_writes));
|
||||||
|
|
||||||
|
|
|
@ -317,7 +317,7 @@ namespace libtorrent
|
||||||
|
|
||||||
string_view internal_file_entry::filename() const
|
string_view internal_file_entry::filename() const
|
||||||
{
|
{
|
||||||
if (name_len != name_is_owned) return { name, size_t(name_len) };
|
if (name_len != name_is_owned) return {name, std::size_t(name_len)};
|
||||||
return name ? string_view(name) : string_view();
|
return name ? string_view(name) : string_view();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,7 +630,7 @@ namespace libtorrent
|
||||||
return m_symlinks[fe.symlink_index];
|
return m_symlinks[fe.symlink_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t file_storage::mtime(int index) const
|
std::time_t file_storage::mtime(int index) const
|
||||||
{
|
{
|
||||||
if (index >= int(m_mtime.size())) return 0;
|
if (index >= int(m_mtime.size())) return 0;
|
||||||
return m_mtime[index];
|
return m_mtime[index];
|
||||||
|
@ -865,7 +865,7 @@ namespace libtorrent
|
||||||
return m_symlinks[fe.symlink_index];
|
return m_symlinks[fe.symlink_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t file_storage::mtime(internal_file_entry const& fe) const
|
std::time_t file_storage::mtime(internal_file_entry const& fe) const
|
||||||
{
|
{
|
||||||
int index = int(&fe - &m_files[0]);
|
int index = int(&fe - &m_files[0]);
|
||||||
if (index >= int(m_mtime.size())) return 0;
|
if (index >= int(m_mtime.size())) return 0;
|
||||||
|
@ -1113,7 +1113,7 @@ namespace libtorrent
|
||||||
std::vector<internal_file_entry>().swap(m_files);
|
std::vector<internal_file_entry>().swap(m_files);
|
||||||
std::vector<char const*>().swap(m_file_hashes);
|
std::vector<char const*>().swap(m_file_hashes);
|
||||||
std::vector<std::string>().swap(m_symlinks);
|
std::vector<std::string>().swap(m_symlinks);
|
||||||
std::vector<time_t>().swap(m_mtime);
|
std::vector<std::time_t>().swap(m_mtime);
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
std::vector<std::int64_t>().swap(m_file_base);
|
std::vector<std::int64_t>().swap(m_file_base);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
// parse header
|
// parse header
|
||||||
std::unique_ptr<std::uint32_t[]> header(new std::uint32_t[m_header_size]);
|
std::unique_ptr<std::uint32_t[]> header(new std::uint32_t[m_header_size]);
|
||||||
file::iovec_t b = {header.get(), size_t(m_header_size) };
|
file::iovec_t b = {header.get(), std::size_t(m_header_size)};
|
||||||
int n = int(m_file.readv(0, b, ec));
|
int n = int(m_file.readv(0, b, ec));
|
||||||
if (ec) return;
|
if (ec) return;
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ namespace libtorrent
|
||||||
// don't hold the lock during disk I/O
|
// don't hold the lock during disk I/O
|
||||||
l.unlock();
|
l.unlock();
|
||||||
|
|
||||||
file::iovec_t v = { buf.get(), size_t(block_to_copy) };
|
file::iovec_t v = {buf.get(), std::size_t(block_to_copy)};
|
||||||
v.iov_len = m_file.readv(slot_offset + piece_offset, v, ec);
|
v.iov_len = m_file.readv(slot_offset + piece_offset, v, ec);
|
||||||
TORRENT_ASSERT(!ec);
|
TORRENT_ASSERT(!ec);
|
||||||
if (ec || v.iov_len == 0) return;
|
if (ec || v.iov_len == 0) return;
|
||||||
|
@ -412,7 +412,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
std::memset(ptr, 0, m_header_size - (ptr - reinterpret_cast<char*>(header.get())));
|
std::memset(ptr, 0, m_header_size - (ptr - reinterpret_cast<char*>(header.get())));
|
||||||
|
|
||||||
file::iovec_t b = {header.get(), size_t(m_header_size) };
|
file::iovec_t b = {header.get(), std::size_t(m_header_size)};
|
||||||
m_file.writev(0, b, ec);
|
m_file.writev(0, b, ec);
|
||||||
if (ec) return;
|
if (ec) return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1459,8 +1459,8 @@ namespace libtorrent
|
||||||
names.append(torrent_name, name_length);
|
names.append(torrent_name, name_length);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (strncmp(torrent_name, "*", name_length) == 0
|
if (std::strncmp(torrent_name, "*", name_length) == 0
|
||||||
|| strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0)
|
|| std::strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_DISABLE_LOGGING
|
#ifdef TORRENT_DISABLE_LOGGING
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
token = xml_parse_error;
|
token = xml_parse_error;
|
||||||
start = "unexpected end of file";
|
start = "unexpected end of file";
|
||||||
callback(token, start, int(strlen(start)), nullptr, 0);
|
callback(token, start, int(std::strlen(start)), nullptr, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
token = xml_parse_error;
|
token = xml_parse_error;
|
||||||
start = "unexpected end of file";
|
start = "unexpected end of file";
|
||||||
callback(token, start, int(strlen(start)), nullptr, 0);
|
callback(token, start, int(std::strlen(start)), nullptr, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
token = xml_parse_error;
|
token = xml_parse_error;
|
||||||
start = "unquoted attribute value";
|
start = "unquoted attribute value";
|
||||||
callback(token, start, int(strlen(start)), nullptr, 0);
|
callback(token, start, int(std::strlen(start)), nullptr, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
char quote = *i;
|
char quote = *i;
|
||||||
|
@ -185,7 +185,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
token = xml_parse_error;
|
token = xml_parse_error;
|
||||||
start = "missing end quote on attribute";
|
start = "missing end quote on attribute";
|
||||||
callback(token, start, int(strlen(start)), nullptr, 0);
|
callback(token, start, int(std::strlen(start)), nullptr, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const int val_len = int(i - val_start);
|
const int val_len = int(i - val_start);
|
||||||
|
|
Loading…
Reference in New Issue