Address compiler warnings #10
This commit is contained in:
parent
bb5a9f9737
commit
f94196d865
@ -44,14 +44,16 @@ public:
|
|||||||
|
|
||||||
explicit packet(data_buffer &&buffer) : buffer_(std::move(buffer)) {}
|
explicit packet(data_buffer &&buffer) : buffer_(std::move(buffer)) {}
|
||||||
|
|
||||||
packet(const packet &p) noexcept = default;
|
packet(const packet &pkt) noexcept = default;
|
||||||
|
|
||||||
packet(packet &&p) noexcept
|
packet(packet &&pkt) noexcept
|
||||||
: buffer_(std::move(p.buffer_)), decode_offset_(p.decode_offset_) {}
|
: buffer_(std::move(pkt.buffer_)), decode_offset_(pkt.decode_offset_) {}
|
||||||
|
|
||||||
|
~packet() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
data_buffer buffer_;
|
data_buffer buffer_;
|
||||||
std::size_t decode_offset_ = 0u;
|
std::size_t decode_offset_ = 0U;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] static auto decode_json(packet &response, json &json_data)
|
[[nodiscard]] static auto decode_json(packet &response, json &json_data)
|
||||||
@ -78,48 +80,46 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] auto decode(void *&ptr) -> error_type;
|
[[nodiscard]] auto decode(void *&ptr) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(std::int8_t &i) -> error_type;
|
[[nodiscard]] auto decode(std::int8_t &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(std::uint8_t &i) -> error_type;
|
[[nodiscard]] auto decode(std::uint8_t &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(std::int16_t &i) -> error_type;
|
[[nodiscard]] auto decode(std::int16_t &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(std::uint16_t &i) -> error_type;
|
[[nodiscard]] auto decode(std::uint16_t &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(std::int32_t &i) -> error_type;
|
[[nodiscard]] auto decode(std::int32_t &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(std::uint32_t &i) -> error_type;
|
[[nodiscard]] auto decode(std::uint32_t &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(std::int64_t &i) -> error_type;
|
[[nodiscard]] auto decode(std::int64_t &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(std::uint64_t &i) -> error_type;
|
[[nodiscard]] auto decode(std::uint64_t &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(remote::open_flags &i) -> error_type {
|
[[nodiscard]] auto decode(remote::open_flags &val) -> error_type {
|
||||||
return decode(reinterpret_cast<std::uint32_t &>(i));
|
return decode(reinterpret_cast<std::uint32_t &>(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto decode(remote::setattr_x &i) -> error_type;
|
[[nodiscard]] auto decode(remote::setattr_x &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(remote::stat &i) -> error_type;
|
[[nodiscard]] auto decode(remote::stat &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(remote::statfs &i) -> error_type;
|
[[nodiscard]] auto decode(remote::statfs &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(remote::statfs_x &i) -> error_type;
|
[[nodiscard]] auto decode(remote::statfs_x &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decode(remote::file_info &i) -> error_type;
|
[[nodiscard]] auto decode(remote::file_info &val) -> error_type;
|
||||||
|
|
||||||
[[nodiscard]] auto decrypt(const std::string &token) -> error_type;
|
[[nodiscard]] auto decrypt(const std::string &token) -> error_type;
|
||||||
|
|
||||||
void encode(const void *buffer, std::size_t size, bool should_reserve = true);
|
void encode(const void *buffer, std::size_t size, bool should_reserve = true);
|
||||||
|
|
||||||
void encode(char *str) { encode(std::string(str ? str : "")); }
|
void encode(const char *str) {
|
||||||
|
encode(std::string(str == nullptr ? "" : str));
|
||||||
void encode(const char *str) { encode(std::string(str ? str : "")); }
|
}
|
||||||
|
|
||||||
void encode(const std::string &str);
|
void encode(const std::string &str);
|
||||||
|
|
||||||
void encode(wchar_t *str);
|
|
||||||
|
|
||||||
void encode(const wchar_t *str);
|
void encode(const wchar_t *str);
|
||||||
|
|
||||||
void encode(const std::wstring &str);
|
void encode(const std::wstring &str);
|
||||||
@ -128,33 +128,35 @@ public:
|
|||||||
encode(static_cast<std::uint64_t>(reinterpret_cast<std::uintptr_t>(ptr)));
|
encode(static_cast<std::uint64_t>(reinterpret_cast<std::uintptr_t>(ptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void encode(std::int8_t i);
|
void encode(std::int8_t val);
|
||||||
|
|
||||||
void encode(std::uint8_t i);
|
void encode(std::uint8_t val);
|
||||||
|
|
||||||
void encode(std::int16_t i);
|
void encode(std::int16_t val);
|
||||||
|
|
||||||
void encode(std::uint16_t i);
|
void encode(std::uint16_t val);
|
||||||
|
|
||||||
void encode(std::int32_t i);
|
void encode(std::int32_t val);
|
||||||
|
|
||||||
void encode(std::uint32_t i);
|
void encode(std::uint32_t val);
|
||||||
|
|
||||||
void encode(std::int64_t i);
|
void encode(std::int64_t val);
|
||||||
|
|
||||||
void encode(std::uint64_t i);
|
void encode(std::uint64_t val);
|
||||||
|
|
||||||
void encode(remote::open_flags i) { encode(static_cast<std::uint32_t>(i)); }
|
void encode(remote::open_flags val) {
|
||||||
|
encode(static_cast<std::uint32_t>(val));
|
||||||
|
}
|
||||||
|
|
||||||
void encode(remote::setattr_x i);
|
void encode(remote::setattr_x val);
|
||||||
|
|
||||||
void encode(remote::stat i);
|
void encode(remote::stat val);
|
||||||
|
|
||||||
void encode(remote::statfs i, bool should_reserve = true);
|
void encode(remote::statfs val, bool should_reserve = true);
|
||||||
|
|
||||||
void encode(remote::statfs_x i);
|
void encode(remote::statfs_x val);
|
||||||
|
|
||||||
void encode(remote::file_info i);
|
void encode(remote::file_info val);
|
||||||
|
|
||||||
void encode_top(const void *buffer, std::size_t size,
|
void encode_top(const void *buffer, std::size_t size,
|
||||||
bool should_reserve = true);
|
bool should_reserve = true);
|
||||||
@ -168,35 +170,35 @@ public:
|
|||||||
static_cast<std::uint64_t>(reinterpret_cast<std::uintptr_t>(ptr)));
|
static_cast<std::uint64_t>(reinterpret_cast<std::uintptr_t>(ptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void encode_top(std::int8_t i);
|
void encode_top(std::int8_t val);
|
||||||
|
|
||||||
void encode_top(std::uint8_t i);
|
void encode_top(std::uint8_t val);
|
||||||
|
|
||||||
void encode_top(std::int16_t i);
|
void encode_top(std::int16_t val);
|
||||||
|
|
||||||
void encode_top(std::uint16_t i);
|
void encode_top(std::uint16_t val);
|
||||||
|
|
||||||
void encode_top(std::int32_t i);
|
void encode_top(std::int32_t val);
|
||||||
|
|
||||||
void encode_top(std::uint32_t i);
|
void encode_top(std::uint32_t val);
|
||||||
|
|
||||||
void encode_top(std::int64_t i);
|
void encode_top(std::int64_t val);
|
||||||
|
|
||||||
void encode_top(std::uint64_t i);
|
void encode_top(std::uint64_t val);
|
||||||
|
|
||||||
void encode_top(remote::open_flags i) {
|
void encode_top(remote::open_flags val) {
|
||||||
encode_top(static_cast<std::uint32_t>(i));
|
encode_top(static_cast<std::uint32_t>(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
void encode_top(remote::setattr_x i);
|
void encode_top(remote::setattr_x val);
|
||||||
|
|
||||||
void encode_top(remote::stat i);
|
void encode_top(remote::stat val);
|
||||||
|
|
||||||
void encode_top(remote::statfs i, bool should_reserve = true);
|
void encode_top(remote::statfs val, bool should_reserve = true);
|
||||||
|
|
||||||
void encode_top(remote::statfs_x i);
|
void encode_top(remote::statfs_x val);
|
||||||
|
|
||||||
void encode_top(remote::file_info i);
|
void encode_top(remote::file_info val);
|
||||||
|
|
||||||
void encrypt(const std::string &token);
|
void encrypt(const std::string &token);
|
||||||
|
|
||||||
@ -211,9 +213,9 @@ public:
|
|||||||
|
|
||||||
auto operator=(data_buffer &&buffer) noexcept -> packet &;
|
auto operator=(data_buffer &&buffer) noexcept -> packet &;
|
||||||
|
|
||||||
auto operator=(const packet &p) noexcept -> packet &;
|
auto operator=(const packet &pkt) noexcept -> packet &;
|
||||||
|
|
||||||
auto operator=(packet &&p) noexcept -> packet &;
|
auto operator=(packet &&pkt) noexcept -> packet &;
|
||||||
|
|
||||||
[[nodiscard]] auto operator[](std::size_t index) -> char & {
|
[[nodiscard]] auto operator[](std::size_t index) -> char & {
|
||||||
return buffer_[index];
|
return buffer_[index];
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
|
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
template <typename data_type>
|
template <typename data_type>
|
||||||
[[nodiscard]] constexpr auto repertory_rand() -> data_type {
|
[[nodiscard]] inline auto repertory_rand() -> data_type {
|
||||||
data_type ret{};
|
data_type ret{};
|
||||||
randombytes_buf(&ret, sizeof(ret));
|
randombytes_buf(&ret, sizeof(ret));
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
namespace repertory {
|
namespace repertory {
|
||||||
void packet::clear() {
|
void packet::clear() {
|
||||||
buffer_.clear();
|
buffer_.clear();
|
||||||
decode_offset_ = 0u;
|
decode_offset_ = 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(std::string &data) -> packet::error_type {
|
auto packet::decode(std::string &data) -> packet::error_type {
|
||||||
@ -59,7 +59,7 @@ auto packet::decode(void *&ptr) -> packet::error_type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(void *buffer, std::size_t size) -> packet::error_type {
|
auto packet::decode(void *buffer, std::size_t size) -> packet::error_type {
|
||||||
if (size) {
|
if (size != 0U) {
|
||||||
const auto read_size =
|
const auto read_size =
|
||||||
utils::calculate_read_size(buffer_.size(), size, decode_offset_);
|
utils::calculate_read_size(buffer_.size(), size, decode_offset_);
|
||||||
if (read_size == size) {
|
if (read_size == size) {
|
||||||
@ -75,153 +75,153 @@ auto packet::decode(void *buffer, std::size_t size) -> packet::error_type {
|
|||||||
return utils::from_api_error(api_error::success);
|
return utils::from_api_error(api_error::success);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(std::int8_t &i) -> packet::error_type {
|
auto packet::decode(std::int8_t &val) -> packet::error_type {
|
||||||
const auto ret = decode(&i, sizeof(i));
|
const auto ret = decode(&val, sizeof(val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
boost::endian::big_to_native_inplace(i);
|
boost::endian::big_to_native_inplace(val);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(std::uint8_t &i) -> packet::error_type {
|
auto packet::decode(std::uint8_t &val) -> packet::error_type {
|
||||||
const auto ret = decode(&i, sizeof(i));
|
const auto ret = decode(&val, sizeof(val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
boost::endian::big_to_native_inplace(i);
|
boost::endian::big_to_native_inplace(val);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(std::int16_t &i) -> packet::error_type {
|
auto packet::decode(std::int16_t &val) -> packet::error_type {
|
||||||
const auto ret = decode(&i, sizeof(i));
|
const auto ret = decode(&val, sizeof(val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
boost::endian::big_to_native_inplace(i);
|
boost::endian::big_to_native_inplace(val);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(std::uint16_t &i) -> packet::error_type {
|
auto packet::decode(std::uint16_t &val) -> packet::error_type {
|
||||||
const auto ret = decode(&i, sizeof(i));
|
const auto ret = decode(&val, sizeof(val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
boost::endian::big_to_native_inplace(i);
|
boost::endian::big_to_native_inplace(val);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(std::int32_t &i) -> packet::error_type {
|
auto packet::decode(std::int32_t &val) -> packet::error_type {
|
||||||
const auto ret = decode(&i, sizeof(i));
|
const auto ret = decode(&val, sizeof(val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
boost::endian::big_to_native_inplace(i);
|
boost::endian::big_to_native_inplace(val);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(std::uint32_t &i) -> packet::error_type {
|
auto packet::decode(std::uint32_t &val) -> packet::error_type {
|
||||||
const auto ret = decode(&i, sizeof(i));
|
const auto ret = decode(&val, sizeof(val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
boost::endian::big_to_native_inplace(i);
|
boost::endian::big_to_native_inplace(val);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(std::int64_t &i) -> packet::error_type {
|
auto packet::decode(std::int64_t &val) -> packet::error_type {
|
||||||
const auto ret = decode(&i, sizeof(i));
|
const auto ret = decode(&val, sizeof(val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
boost::endian::big_to_native_inplace(i);
|
boost::endian::big_to_native_inplace(val);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(std::uint64_t &i) -> packet::error_type {
|
auto packet::decode(std::uint64_t &val) -> packet::error_type {
|
||||||
const auto ret = decode(&i, sizeof(i));
|
const auto ret = decode(&val, sizeof(val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
boost::endian::big_to_native_inplace(i);
|
boost::endian::big_to_native_inplace(val);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(remote::setattr_x &i) -> packet::error_type {
|
auto packet::decode(remote::setattr_x &val) -> packet::error_type {
|
||||||
const auto ret = decode(&i, sizeof(i));
|
const auto ret = decode(&val, sizeof(val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
boost::endian::big_to_native_inplace(i.acctime);
|
boost::endian::big_to_native_inplace(val.acctime);
|
||||||
boost::endian::big_to_native_inplace(i.bkuptime);
|
boost::endian::big_to_native_inplace(val.bkuptime);
|
||||||
boost::endian::big_to_native_inplace(i.chgtime);
|
boost::endian::big_to_native_inplace(val.chgtime);
|
||||||
boost::endian::big_to_native_inplace(i.crtime);
|
boost::endian::big_to_native_inplace(val.crtime);
|
||||||
boost::endian::big_to_native_inplace(i.flags);
|
boost::endian::big_to_native_inplace(val.flags);
|
||||||
boost::endian::big_to_native_inplace(i.gid);
|
boost::endian::big_to_native_inplace(val.gid);
|
||||||
boost::endian::big_to_native_inplace(i.mode);
|
boost::endian::big_to_native_inplace(val.mode);
|
||||||
boost::endian::big_to_native_inplace(i.modtime);
|
boost::endian::big_to_native_inplace(val.modtime);
|
||||||
boost::endian::big_to_native_inplace(i.size);
|
boost::endian::big_to_native_inplace(val.size);
|
||||||
boost::endian::big_to_native_inplace(i.uid);
|
boost::endian::big_to_native_inplace(val.uid);
|
||||||
boost::endian::big_to_native_inplace(i.valid);
|
boost::endian::big_to_native_inplace(val.valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(remote::stat &i) -> packet::error_type {
|
auto packet::decode(remote::stat &val) -> packet::error_type {
|
||||||
const auto ret = decode(&i, sizeof(i));
|
const auto ret = decode(&val, sizeof(val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
boost::endian::big_to_native_inplace(i.st_mode);
|
boost::endian::big_to_native_inplace(val.st_mode);
|
||||||
boost::endian::big_to_native_inplace(i.st_nlink);
|
boost::endian::big_to_native_inplace(val.st_nlink);
|
||||||
boost::endian::big_to_native_inplace(i.st_uid);
|
boost::endian::big_to_native_inplace(val.st_uid);
|
||||||
boost::endian::big_to_native_inplace(i.st_gid);
|
boost::endian::big_to_native_inplace(val.st_gid);
|
||||||
boost::endian::big_to_native_inplace(i.st_atimespec);
|
boost::endian::big_to_native_inplace(val.st_atimespec);
|
||||||
boost::endian::big_to_native_inplace(i.st_mtimespec);
|
boost::endian::big_to_native_inplace(val.st_mtimespec);
|
||||||
boost::endian::big_to_native_inplace(i.st_ctimespec);
|
boost::endian::big_to_native_inplace(val.st_ctimespec);
|
||||||
boost::endian::big_to_native_inplace(i.st_birthtimespec);
|
boost::endian::big_to_native_inplace(val.st_birthtimespec);
|
||||||
boost::endian::big_to_native_inplace(i.st_size);
|
boost::endian::big_to_native_inplace(val.st_size);
|
||||||
boost::endian::big_to_native_inplace(i.st_blocks);
|
boost::endian::big_to_native_inplace(val.st_blocks);
|
||||||
boost::endian::big_to_native_inplace(i.st_blksize);
|
boost::endian::big_to_native_inplace(val.st_blksize);
|
||||||
boost::endian::big_to_native_inplace(i.st_flags);
|
boost::endian::big_to_native_inplace(val.st_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(remote::statfs &i) -> packet::error_type {
|
auto packet::decode(remote::statfs &val) -> packet::error_type {
|
||||||
const auto ret = decode(&i, sizeof(i));
|
const auto ret = decode(&val, sizeof(val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
boost::endian::big_to_native_inplace(i.f_bavail);
|
boost::endian::big_to_native_inplace(val.f_bavail);
|
||||||
boost::endian::big_to_native_inplace(i.f_bfree);
|
boost::endian::big_to_native_inplace(val.f_bfree);
|
||||||
boost::endian::big_to_native_inplace(i.f_blocks);
|
boost::endian::big_to_native_inplace(val.f_blocks);
|
||||||
boost::endian::big_to_native_inplace(i.f_favail);
|
boost::endian::big_to_native_inplace(val.f_favail);
|
||||||
boost::endian::big_to_native_inplace(i.f_ffree);
|
boost::endian::big_to_native_inplace(val.f_ffree);
|
||||||
boost::endian::big_to_native_inplace(i.f_files);
|
boost::endian::big_to_native_inplace(val.f_files);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(remote::statfs_x &i) -> packet::error_type {
|
auto packet::decode(remote::statfs_x &val) -> packet::error_type {
|
||||||
auto ret = decode(*dynamic_cast<remote::statfs *>(&i));
|
auto ret = decode(*dynamic_cast<remote::statfs *>(&val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = decode(&i.f_mntfromname[0], 1024);
|
ret = decode(&val.f_mntfromname[0U], sizeof(val.f_mntfromname));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode(remote::file_info &i) -> packet::error_type {
|
auto packet::decode(remote::file_info &val) -> packet::error_type {
|
||||||
const auto ret = decode(&i, sizeof(i));
|
const auto ret = decode(&val, sizeof(val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
boost::endian::big_to_native_inplace(i.AllocationSize);
|
boost::endian::big_to_native_inplace(val.AllocationSize);
|
||||||
boost::endian::big_to_native_inplace(i.ChangeTime);
|
boost::endian::big_to_native_inplace(val.ChangeTime);
|
||||||
boost::endian::big_to_native_inplace(i.CreationTime);
|
boost::endian::big_to_native_inplace(val.CreationTime);
|
||||||
boost::endian::big_to_native_inplace(i.EaSize);
|
boost::endian::big_to_native_inplace(val.EaSize);
|
||||||
boost::endian::big_to_native_inplace(i.FileAttributes);
|
boost::endian::big_to_native_inplace(val.FileAttributes);
|
||||||
boost::endian::big_to_native_inplace(i.FileSize);
|
boost::endian::big_to_native_inplace(val.FileSize);
|
||||||
boost::endian::big_to_native_inplace(i.HardLinks);
|
boost::endian::big_to_native_inplace(val.HardLinks);
|
||||||
boost::endian::big_to_native_inplace(i.IndexNumber);
|
boost::endian::big_to_native_inplace(val.IndexNumber);
|
||||||
boost::endian::big_to_native_inplace(i.LastAccessTime);
|
boost::endian::big_to_native_inplace(val.LastAccessTime);
|
||||||
boost::endian::big_to_native_inplace(i.LastWriteTime);
|
boost::endian::big_to_native_inplace(val.LastWriteTime);
|
||||||
boost::endian::big_to_native_inplace(i.ReparseTag);
|
boost::endian::big_to_native_inplace(val.ReparseTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::decode_json(packet &response, json &json_data) -> int {
|
auto packet::decode_json(packet &response, json &json_data) -> int {
|
||||||
int ret = 0;
|
|
||||||
std::string data;
|
std::string data;
|
||||||
if ((ret = response.decode(data)) == 0) {
|
auto ret = response.decode(data);
|
||||||
|
if (ret == 0) {
|
||||||
try {
|
try {
|
||||||
json_data = json::parse(data);
|
json_data = json::parse(data);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
@ -253,7 +253,7 @@ auto packet::decrypt(const std::string &token) -> packet::error_type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(const void *buffer, std::size_t size, bool should_reserve) {
|
void packet::encode(const void *buffer, std::size_t size, bool should_reserve) {
|
||||||
if (size) {
|
if (size != 0U) {
|
||||||
if (should_reserve) {
|
if (should_reserve) {
|
||||||
buffer_.reserve(buffer_.size() + size);
|
buffer_.reserve(buffer_.size() + size);
|
||||||
}
|
}
|
||||||
@ -263,133 +263,130 @@ void packet::encode(const void *buffer, std::size_t size, bool should_reserve) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(const std::string &str) {
|
void packet::encode(const std::string &str) {
|
||||||
const auto len = strnlen(&str[0], str.size());
|
const auto len = strnlen(str.c_str(), str.size());
|
||||||
buffer_.reserve(len + 1 + buffer_.size());
|
buffer_.reserve(len + 1 + buffer_.size());
|
||||||
encode(&str[0], len, false);
|
encode(str.c_str(), len, false);
|
||||||
buffer_.emplace_back(0);
|
buffer_.emplace_back(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(wchar_t *str) {
|
|
||||||
encode(utils::string::to_utf8(str ? str : L""));
|
|
||||||
}
|
|
||||||
|
|
||||||
void packet::encode(const wchar_t *str) {
|
void packet::encode(const wchar_t *str) {
|
||||||
encode(utils::string::to_utf8(str ? str : L""));
|
encode(utils::string::to_utf8(str == nullptr ? L"" : str));
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(const std::wstring &str) {
|
void packet::encode(const std::wstring &str) {
|
||||||
encode(utils::string::to_utf8(str));
|
encode(utils::string::to_utf8(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(std::int8_t i) {
|
void packet::encode(std::int8_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode(&i, sizeof(i), true);
|
encode(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(std::uint8_t i) {
|
void packet::encode(std::uint8_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode(&i, sizeof(i), true);
|
encode(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(std::int16_t i) {
|
void packet::encode(std::int16_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode(&i, sizeof(i), true);
|
encode(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(std::uint16_t i) {
|
void packet::encode(std::uint16_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode(&i, sizeof(i), true);
|
encode(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(std::int32_t i) {
|
void packet::encode(std::int32_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode(&i, sizeof(i), true);
|
encode(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(std::uint32_t i) {
|
void packet::encode(std::uint32_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode(&i, sizeof(i), true);
|
encode(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(std::int64_t i) {
|
void packet::encode(std::int64_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode(&i, sizeof(i), true);
|
encode(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(std::uint64_t i) {
|
void packet::encode(std::uint64_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode(&i, sizeof(i), true);
|
encode(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(remote::setattr_x i) {
|
void packet::encode(remote::setattr_x val) {
|
||||||
boost::endian::native_to_big_inplace(i.acctime);
|
boost::endian::native_to_big_inplace(val.acctime);
|
||||||
boost::endian::native_to_big_inplace(i.bkuptime);
|
boost::endian::native_to_big_inplace(val.bkuptime);
|
||||||
boost::endian::native_to_big_inplace(i.chgtime);
|
boost::endian::native_to_big_inplace(val.chgtime);
|
||||||
boost::endian::native_to_big_inplace(i.crtime);
|
boost::endian::native_to_big_inplace(val.crtime);
|
||||||
boost::endian::native_to_big_inplace(i.flags);
|
boost::endian::native_to_big_inplace(val.flags);
|
||||||
boost::endian::native_to_big_inplace(i.gid);
|
boost::endian::native_to_big_inplace(val.gid);
|
||||||
boost::endian::native_to_big_inplace(i.mode);
|
boost::endian::native_to_big_inplace(val.mode);
|
||||||
boost::endian::native_to_big_inplace(i.modtime);
|
boost::endian::native_to_big_inplace(val.modtime);
|
||||||
boost::endian::native_to_big_inplace(i.size);
|
boost::endian::native_to_big_inplace(val.size);
|
||||||
boost::endian::native_to_big_inplace(i.uid);
|
boost::endian::native_to_big_inplace(val.uid);
|
||||||
boost::endian::native_to_big_inplace(i.valid);
|
boost::endian::native_to_big_inplace(val.valid);
|
||||||
|
|
||||||
encode(&i, sizeof(i), true);
|
encode(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(remote::stat i) {
|
void packet::encode(remote::stat val) {
|
||||||
boost::endian::native_to_big_inplace(i.st_mode);
|
boost::endian::native_to_big_inplace(val.st_mode);
|
||||||
boost::endian::native_to_big_inplace(i.st_nlink);
|
boost::endian::native_to_big_inplace(val.st_nlink);
|
||||||
boost::endian::native_to_big_inplace(i.st_uid);
|
boost::endian::native_to_big_inplace(val.st_uid);
|
||||||
boost::endian::native_to_big_inplace(i.st_gid);
|
boost::endian::native_to_big_inplace(val.st_gid);
|
||||||
boost::endian::native_to_big_inplace(i.st_atimespec);
|
boost::endian::native_to_big_inplace(val.st_atimespec);
|
||||||
boost::endian::native_to_big_inplace(i.st_mtimespec);
|
boost::endian::native_to_big_inplace(val.st_mtimespec);
|
||||||
boost::endian::native_to_big_inplace(i.st_ctimespec);
|
boost::endian::native_to_big_inplace(val.st_ctimespec);
|
||||||
boost::endian::native_to_big_inplace(i.st_birthtimespec);
|
boost::endian::native_to_big_inplace(val.st_birthtimespec);
|
||||||
boost::endian::native_to_big_inplace(i.st_size);
|
boost::endian::native_to_big_inplace(val.st_size);
|
||||||
boost::endian::native_to_big_inplace(i.st_blocks);
|
boost::endian::native_to_big_inplace(val.st_blocks);
|
||||||
boost::endian::native_to_big_inplace(i.st_blksize);
|
boost::endian::native_to_big_inplace(val.st_blksize);
|
||||||
boost::endian::native_to_big_inplace(i.st_flags);
|
boost::endian::native_to_big_inplace(val.st_flags);
|
||||||
|
|
||||||
encode(&i, sizeof(i), true);
|
encode(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(remote::statfs i, bool should_reserve) {
|
void packet::encode(remote::statfs val, bool should_reserve) {
|
||||||
boost::endian::native_to_big_inplace(i.f_bavail);
|
boost::endian::native_to_big_inplace(val.f_bavail);
|
||||||
boost::endian::native_to_big_inplace(i.f_bfree);
|
boost::endian::native_to_big_inplace(val.f_bfree);
|
||||||
boost::endian::native_to_big_inplace(i.f_blocks);
|
boost::endian::native_to_big_inplace(val.f_blocks);
|
||||||
boost::endian::native_to_big_inplace(i.f_favail);
|
boost::endian::native_to_big_inplace(val.f_favail);
|
||||||
boost::endian::native_to_big_inplace(i.f_ffree);
|
boost::endian::native_to_big_inplace(val.f_ffree);
|
||||||
boost::endian::native_to_big_inplace(i.f_files);
|
boost::endian::native_to_big_inplace(val.f_files);
|
||||||
|
|
||||||
encode(&i, sizeof(remote::statfs), should_reserve);
|
encode(&val, sizeof(remote::statfs), should_reserve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(remote::statfs_x i) {
|
void packet::encode(remote::statfs_x val) {
|
||||||
buffer_.reserve(buffer_.size() + sizeof(remote::statfs) + 1024);
|
buffer_.reserve(buffer_.size() + sizeof(remote::statfs) +
|
||||||
encode(*dynamic_cast<remote::statfs *>(&i), false);
|
sizeof(val.f_mntfromname));
|
||||||
encode(&i.f_mntfromname[0], 1024, false);
|
encode(*dynamic_cast<remote::statfs *>(&val), false);
|
||||||
|
encode(&val.f_mntfromname[0], sizeof(val.f_mntfromname), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(remote::file_info i) {
|
void packet::encode(remote::file_info val) {
|
||||||
boost::endian::native_to_big_inplace(i.FileAttributes);
|
boost::endian::native_to_big_inplace(val.FileAttributes);
|
||||||
boost::endian::native_to_big_inplace(i.ReparseTag);
|
boost::endian::native_to_big_inplace(val.ReparseTag);
|
||||||
boost::endian::native_to_big_inplace(i.AllocationSize);
|
boost::endian::native_to_big_inplace(val.AllocationSize);
|
||||||
boost::endian::native_to_big_inplace(i.FileSize);
|
boost::endian::native_to_big_inplace(val.FileSize);
|
||||||
boost::endian::native_to_big_inplace(i.CreationTime);
|
boost::endian::native_to_big_inplace(val.CreationTime);
|
||||||
boost::endian::native_to_big_inplace(i.LastAccessTime);
|
boost::endian::native_to_big_inplace(val.LastAccessTime);
|
||||||
boost::endian::native_to_big_inplace(i.LastWriteTime);
|
boost::endian::native_to_big_inplace(val.LastWriteTime);
|
||||||
boost::endian::native_to_big_inplace(i.ChangeTime);
|
boost::endian::native_to_big_inplace(val.ChangeTime);
|
||||||
boost::endian::native_to_big_inplace(i.IndexNumber);
|
boost::endian::native_to_big_inplace(val.IndexNumber);
|
||||||
boost::endian::native_to_big_inplace(i.HardLinks);
|
boost::endian::native_to_big_inplace(val.HardLinks);
|
||||||
boost::endian::native_to_big_inplace(i.EaSize);
|
boost::endian::native_to_big_inplace(val.EaSize);
|
||||||
|
|
||||||
encode(&i, sizeof(i), true);
|
encode(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(const void *buffer, std::size_t size,
|
void packet::encode_top(const void *buffer, std::size_t size,
|
||||||
bool should_reserve) {
|
bool should_reserve) {
|
||||||
if (size) {
|
if (size != 0U) {
|
||||||
if (should_reserve) {
|
if (should_reserve) {
|
||||||
buffer_.reserve(buffer_.size() + size);
|
buffer_.reserve(buffer_.size() + size);
|
||||||
}
|
}
|
||||||
@ -401,7 +398,7 @@ void packet::encode_top(const void *buffer, std::size_t size,
|
|||||||
void packet::encode_top(const std::string &str) {
|
void packet::encode_top(const std::string &str) {
|
||||||
const auto len = strnlen(str.c_str(), str.size());
|
const auto len = strnlen(str.c_str(), str.size());
|
||||||
buffer_.reserve(len + 1U + buffer_.size());
|
buffer_.reserve(len + 1U + buffer_.size());
|
||||||
encode_top(&str[0], len, false);
|
encode_top(str.c_str(), len, false);
|
||||||
buffer_.insert(buffer_.begin() + static_cast<std::int32_t>(len), 0);
|
buffer_.insert(buffer_.begin() + static_cast<std::int32_t>(len), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,110 +406,111 @@ void packet::encode_top(const std::wstring &str) {
|
|||||||
encode_top(utils::string::to_utf8(str));
|
encode_top(utils::string::to_utf8(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(std::int8_t i) {
|
void packet::encode_top(std::int8_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode_top(&i, sizeof(i), true);
|
encode_top(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(std::uint8_t i) {
|
void packet::encode_top(std::uint8_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode_top(&i, sizeof(i), true);
|
encode_top(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(std::int16_t i) {
|
void packet::encode_top(std::int16_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode_top(&i, sizeof(i), true);
|
encode_top(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(std::uint16_t i) {
|
void packet::encode_top(std::uint16_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode_top(&i, sizeof(i), true);
|
encode_top(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(std::int32_t i) {
|
void packet::encode_top(std::int32_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode_top(&i, sizeof(i), true);
|
encode_top(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(std::uint32_t i) {
|
void packet::encode_top(std::uint32_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode_top(&i, sizeof(i), true);
|
encode_top(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(std::int64_t i) {
|
void packet::encode_top(std::int64_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode_top(&i, sizeof(i), true);
|
encode_top(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(std::uint64_t i) {
|
void packet::encode_top(std::uint64_t val) {
|
||||||
boost::endian::native_to_big_inplace(i);
|
boost::endian::native_to_big_inplace(val);
|
||||||
encode_top(&i, sizeof(i), true);
|
encode_top(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(remote::setattr_x i) {
|
void packet::encode_top(remote::setattr_x val) {
|
||||||
boost::endian::native_to_big_inplace(i.acctime);
|
boost::endian::native_to_big_inplace(val.acctime);
|
||||||
boost::endian::native_to_big_inplace(i.bkuptime);
|
boost::endian::native_to_big_inplace(val.bkuptime);
|
||||||
boost::endian::native_to_big_inplace(i.chgtime);
|
boost::endian::native_to_big_inplace(val.chgtime);
|
||||||
boost::endian::native_to_big_inplace(i.crtime);
|
boost::endian::native_to_big_inplace(val.crtime);
|
||||||
boost::endian::native_to_big_inplace(i.flags);
|
boost::endian::native_to_big_inplace(val.flags);
|
||||||
boost::endian::native_to_big_inplace(i.gid);
|
boost::endian::native_to_big_inplace(val.gid);
|
||||||
boost::endian::native_to_big_inplace(i.mode);
|
boost::endian::native_to_big_inplace(val.mode);
|
||||||
boost::endian::native_to_big_inplace(i.modtime);
|
boost::endian::native_to_big_inplace(val.modtime);
|
||||||
boost::endian::native_to_big_inplace(i.size);
|
boost::endian::native_to_big_inplace(val.size);
|
||||||
boost::endian::native_to_big_inplace(i.uid);
|
boost::endian::native_to_big_inplace(val.uid);
|
||||||
boost::endian::native_to_big_inplace(i.valid);
|
boost::endian::native_to_big_inplace(val.valid);
|
||||||
|
|
||||||
encode_top(&i, sizeof(i), true);
|
encode_top(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(remote::stat i) {
|
void packet::encode_top(remote::stat val) {
|
||||||
boost::endian::native_to_big_inplace(i.st_mode);
|
boost::endian::native_to_big_inplace(val.st_mode);
|
||||||
boost::endian::native_to_big_inplace(i.st_nlink);
|
boost::endian::native_to_big_inplace(val.st_nlink);
|
||||||
boost::endian::native_to_big_inplace(i.st_uid);
|
boost::endian::native_to_big_inplace(val.st_uid);
|
||||||
boost::endian::native_to_big_inplace(i.st_gid);
|
boost::endian::native_to_big_inplace(val.st_gid);
|
||||||
boost::endian::native_to_big_inplace(i.st_atimespec);
|
boost::endian::native_to_big_inplace(val.st_atimespec);
|
||||||
boost::endian::native_to_big_inplace(i.st_mtimespec);
|
boost::endian::native_to_big_inplace(val.st_mtimespec);
|
||||||
boost::endian::native_to_big_inplace(i.st_ctimespec);
|
boost::endian::native_to_big_inplace(val.st_ctimespec);
|
||||||
boost::endian::native_to_big_inplace(i.st_birthtimespec);
|
boost::endian::native_to_big_inplace(val.st_birthtimespec);
|
||||||
boost::endian::native_to_big_inplace(i.st_size);
|
boost::endian::native_to_big_inplace(val.st_size);
|
||||||
boost::endian::native_to_big_inplace(i.st_blocks);
|
boost::endian::native_to_big_inplace(val.st_blocks);
|
||||||
boost::endian::native_to_big_inplace(i.st_blksize);
|
boost::endian::native_to_big_inplace(val.st_blksize);
|
||||||
boost::endian::native_to_big_inplace(i.st_flags);
|
boost::endian::native_to_big_inplace(val.st_flags);
|
||||||
|
|
||||||
encode_top(&i, sizeof(i), true);
|
encode_top(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(remote::statfs i, bool should_reserve) {
|
void packet::encode_top(remote::statfs val, bool should_reserve) {
|
||||||
boost::endian::native_to_big_inplace(i.f_bavail);
|
boost::endian::native_to_big_inplace(val.f_bavail);
|
||||||
boost::endian::native_to_big_inplace(i.f_bfree);
|
boost::endian::native_to_big_inplace(val.f_bfree);
|
||||||
boost::endian::native_to_big_inplace(i.f_blocks);
|
boost::endian::native_to_big_inplace(val.f_blocks);
|
||||||
boost::endian::native_to_big_inplace(i.f_favail);
|
boost::endian::native_to_big_inplace(val.f_favail);
|
||||||
boost::endian::native_to_big_inplace(i.f_ffree);
|
boost::endian::native_to_big_inplace(val.f_ffree);
|
||||||
boost::endian::native_to_big_inplace(i.f_files);
|
boost::endian::native_to_big_inplace(val.f_files);
|
||||||
|
|
||||||
encode_top(&i, sizeof(remote::statfs), should_reserve);
|
encode_top(&val, sizeof(remote::statfs), should_reserve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(remote::statfs_x i) {
|
void packet::encode_top(remote::statfs_x val) {
|
||||||
buffer_.reserve(buffer_.size() + sizeof(remote::statfs) + 1024);
|
buffer_.reserve(buffer_.size() + sizeof(remote::statfs) +
|
||||||
encode_top(&i.f_mntfromname[0], 1024, false);
|
sizeof(val.f_mntfromname));
|
||||||
encode_top(*dynamic_cast<remote::statfs *>(&i), false);
|
encode_top(&val.f_mntfromname[0], sizeof(val.f_mntfromname), false);
|
||||||
|
encode_top(*dynamic_cast<remote::statfs *>(&val), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode_top(remote::file_info i) {
|
void packet::encode_top(remote::file_info val) {
|
||||||
boost::endian::native_to_big_inplace(i.FileAttributes);
|
boost::endian::native_to_big_inplace(val.FileAttributes);
|
||||||
boost::endian::native_to_big_inplace(i.ReparseTag);
|
boost::endian::native_to_big_inplace(val.ReparseTag);
|
||||||
boost::endian::native_to_big_inplace(i.AllocationSize);
|
boost::endian::native_to_big_inplace(val.AllocationSize);
|
||||||
boost::endian::native_to_big_inplace(i.FileSize);
|
boost::endian::native_to_big_inplace(val.FileSize);
|
||||||
boost::endian::native_to_big_inplace(i.CreationTime);
|
boost::endian::native_to_big_inplace(val.CreationTime);
|
||||||
boost::endian::native_to_big_inplace(i.LastAccessTime);
|
boost::endian::native_to_big_inplace(val.LastAccessTime);
|
||||||
boost::endian::native_to_big_inplace(i.LastWriteTime);
|
boost::endian::native_to_big_inplace(val.LastWriteTime);
|
||||||
boost::endian::native_to_big_inplace(i.ChangeTime);
|
boost::endian::native_to_big_inplace(val.ChangeTime);
|
||||||
boost::endian::native_to_big_inplace(i.IndexNumber);
|
boost::endian::native_to_big_inplace(val.IndexNumber);
|
||||||
boost::endian::native_to_big_inplace(i.HardLinks);
|
boost::endian::native_to_big_inplace(val.HardLinks);
|
||||||
boost::endian::native_to_big_inplace(i.EaSize);
|
boost::endian::native_to_big_inplace(val.EaSize);
|
||||||
|
|
||||||
encode_top(&i, sizeof(i), true);
|
encode_top(&val, sizeof(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encrypt(const std::string &token) {
|
void packet::encrypt(const std::string &token) {
|
||||||
@ -550,19 +548,19 @@ auto packet::operator=(data_buffer &&buffer) noexcept -> packet & {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::operator=(const packet &p) noexcept -> packet & {
|
auto packet::operator=(const packet &pkt) noexcept -> packet & {
|
||||||
if (this != &p) {
|
if (this != &pkt) {
|
||||||
buffer_ = p.buffer_;
|
buffer_ = pkt.buffer_;
|
||||||
decode_offset_ = p.decode_offset_;
|
decode_offset_ = pkt.decode_offset_;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto packet::operator=(packet &&p) noexcept -> packet & {
|
auto packet::operator=(packet &&pkt) noexcept -> packet & {
|
||||||
if (this != &p) {
|
if (this != &pkt) {
|
||||||
buffer_ = std::move(p.buffer_);
|
buffer_ = std::move(pkt.buffer_);
|
||||||
decode_offset_ = p.decode_offset_;
|
decode_offset_ = pkt.decode_offset_;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "utils/native_file.hpp"
|
#include "utils/native_file.hpp"
|
||||||
#include "utils/path_utils.hpp"
|
#include "utils/path_utils.hpp"
|
||||||
#include "utils/string_utils.hpp"
|
#include "utils/string_utils.hpp"
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
namespace repertory::utils {
|
namespace repertory::utils {
|
||||||
void calculate_allocation_size(bool directory, std::uint64_t file_size,
|
void calculate_allocation_size(bool directory, std::uint64_t file_size,
|
||||||
@ -244,13 +245,19 @@ auto get_next_available_port(std::uint16_t first_port,
|
|||||||
std::uint16_t &available_port) -> bool {
|
std::uint16_t &available_port) -> bool {
|
||||||
using namespace boost::asio;
|
using namespace boost::asio;
|
||||||
using ip::tcp;
|
using ip::tcp;
|
||||||
boost::system::error_code error_code;
|
|
||||||
do {
|
boost::system::error_code error_code{};
|
||||||
io_service svc;
|
while (first_port != 0U) {
|
||||||
|
io_service svc{};
|
||||||
tcp::acceptor acceptor(svc);
|
tcp::acceptor acceptor(svc);
|
||||||
acceptor.open(tcp::v4(), error_code) ||
|
acceptor.open(tcp::v4(), error_code) ||
|
||||||
acceptor.bind({tcp::v4(), first_port}, error_code);
|
acceptor.bind({tcp::v4(), first_port}, error_code);
|
||||||
} while (error_code && (first_port++ < 65535U));
|
if (not error_code) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
++first_port;
|
||||||
|
}
|
||||||
|
|
||||||
if (not error_code) {
|
if (not error_code) {
|
||||||
available_port = first_port;
|
available_port = first_port;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user