From e1ac9efaaa0fc9df67542c308db6e537870345ea Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Thu, 8 Aug 2024 19:03:55 -0500 Subject: [PATCH] refactor --- .../include/drives/remote/remote_server_base.hpp | 2 +- repertory/librepertory/src/comm/packet/packet.cpp | 2 +- repertory/librepertory/src/utils/file_utils.cpp | 14 +++++++------- support/test/src/utils/file_test.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/repertory/librepertory/include/drives/remote/remote_server_base.hpp b/repertory/librepertory/include/drives/remote/remote_server_base.hpp index 91a3a1ad..2c23911e 100644 --- a/repertory/librepertory/include/drives/remote/remote_server_base.hpp +++ b/repertory/librepertory/include/drives/remote/remote_server_base.hpp @@ -1269,7 +1269,7 @@ public: data_buffer buffer(write_size); if ((ret = request->decode(buffer.data(), buffer.size())) == 0) { buffer = macaron::Base64::Decode( - std::string{buffer.begin(), buffer.end()}); + std::string(buffer.begin(), buffer.end())); write_size = buffer.size(); remote::file_offset write_offset{}; diff --git a/repertory/librepertory/src/comm/packet/packet.cpp b/repertory/librepertory/src/comm/packet/packet.cpp index f1907c0d..ecab6c9b 100644 --- a/repertory/librepertory/src/comm/packet/packet.cpp +++ b/repertory/librepertory/src/comm/packet/packet.cpp @@ -38,7 +38,7 @@ void packet::clear() { auto packet::decode(std::string &data) -> packet::error_type { const auto *str = reinterpret_cast(&buffer_[decode_offset_]); const auto length = strnlen(str, buffer_.size() - decode_offset_); - data = std::string{str, length}; + data = std::string(str, length); decode_offset_ += (length + 1); return utils::from_api_error(api_error::success); diff --git a/repertory/librepertory/src/utils/file_utils.cpp b/repertory/librepertory/src/utils/file_utils.cpp index 35a45001..81c9069a 100644 --- a/repertory/librepertory/src/utils/file_utils.cpp +++ b/repertory/librepertory/src/utils/file_utils.cpp @@ -277,16 +277,16 @@ auto generate_sha256(const std::string &file_path) -> std::string { std::to_string(res)); } - auto nf = utils::file::file::open_file(file_path); - if (not *nf) { - throw std::runtime_error("failed to open file|" + file_path); - } - { - data_buffer buffer(nf->get_read_buffer_size()); + auto input_file = utils::file::file::open_file(file_path); + if (not *input_file) { + throw std::runtime_error("failed to open file|" + file_path); + } + + data_buffer buffer(input_file->get_read_buffer_size()); std::uint64_t read_offset{0U}; std::size_t bytes_read{0U}; - while (nf->read(buffer, read_offset, &bytes_read)) { + while (input_file->read(buffer, read_offset, &bytes_read)) { if (not bytes_read) { break; } diff --git a/support/test/src/utils/file_test.cpp b/support/test/src/utils/file_test.cpp index fba27102..a3b6b7f3 100644 --- a/support/test/src/utils/file_test.cpp +++ b/support/test/src/utils/file_test.cpp @@ -131,7 +131,7 @@ TEST(utils_file, read_and_write_json_file_encrypted) { decrypted_data)); EXPECT_STREQ(data.dump().c_str(), nlohmann::json::parse( - std::string{decrypted_data.begin(), decrypted_data.end()}) + std::string(decrypted_data.begin(), decrypted_data.end())) .dump() .c_str()); }