abstract aways file2rwmapped construction to lower visibility
This commit is contained in:
parent
3fcfbc11a4
commit
f730844771
@ -47,6 +47,8 @@ add_library(solanaceae_sha1_ngcft1
|
|||||||
# hacky deps
|
# hacky deps
|
||||||
./solanaceae/ngc_ft1_sha1/mio.hpp
|
./solanaceae/ngc_ft1_sha1/mio.hpp
|
||||||
./solanaceae/ngc_ft1_sha1/file_rw_mapped.hpp
|
./solanaceae/ngc_ft1_sha1/file_rw_mapped.hpp
|
||||||
|
./solanaceae/ngc_ft1_sha1/file_constructor.hpp
|
||||||
|
./solanaceae/ngc_ft1_sha1/file_constructor.cpp
|
||||||
|
|
||||||
./solanaceae/ngc_ft1_sha1/hash_utils.hpp
|
./solanaceae/ngc_ft1_sha1/hash_utils.hpp
|
||||||
./solanaceae/ngc_ft1_sha1/hash_utils.cpp
|
./solanaceae/ngc_ft1_sha1/hash_utils.cpp
|
||||||
|
8
solanaceae/ngc_ft1_sha1/file_constructor.cpp
Normal file
8
solanaceae/ngc_ft1_sha1/file_constructor.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "./file_constructor.hpp"
|
||||||
|
|
||||||
|
#include "./file_rw_mapped.hpp"
|
||||||
|
|
||||||
|
std::unique_ptr<File2I> construct_file2_rw_mapped(std::string_view file_path, int64_t file_size) {
|
||||||
|
return std::make_unique<File2RWMapped>(file_path, file_size);
|
||||||
|
}
|
||||||
|
|
9
solanaceae/ngc_ft1_sha1/file_constructor.hpp
Normal file
9
solanaceae/ngc_ft1_sha1/file_constructor.hpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <solanaceae/file/file2.hpp>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
std::unique_ptr<File2I> construct_file2_rw_mapped(std::string_view file_path, int64_t file_size = -1);
|
||||||
|
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <entt/container/dense_set.hpp>
|
#include <entt/container/dense_set.hpp>
|
||||||
|
|
||||||
#include "./file_rw_mapped.hpp"
|
#include "./file_constructor.hpp"
|
||||||
|
|
||||||
#include "./components.hpp"
|
#include "./components.hpp"
|
||||||
#include "./contact_components.hpp"
|
#include "./contact_components.hpp"
|
||||||
@ -473,7 +473,7 @@ bool SHA1_NGCFT1::onEvent(const Message::Events::MessageUpdated& e) {
|
|||||||
ce.emplace<Message::Components::Transfer::FileInfoLocal>(std::vector{full_file_path});
|
ce.emplace<Message::Components::Transfer::FileInfoLocal>(std::vector{full_file_path});
|
||||||
|
|
||||||
const bool file_exists = std::filesystem::exists(full_file_path);
|
const bool file_exists = std::filesystem::exists(full_file_path);
|
||||||
std::unique_ptr<File2I> file_impl = std::make_unique<File2RWMapped>(full_file_path, info.file_size);
|
std::unique_ptr<File2I> file_impl = construct_file2_rw_mapped(full_file_path, info.file_size);
|
||||||
|
|
||||||
if (!file_impl->isGood()) {
|
if (!file_impl->isGood()) {
|
||||||
std::cerr << "SHA1_NGCFT1 error: failed opening file '" << full_file_path << "'!\n";
|
std::cerr << "SHA1_NGCFT1 error: failed opening file '" << full_file_path << "'!\n";
|
||||||
@ -953,7 +953,7 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_done& e) {
|
|||||||
// HACK: remap file, to clear ram
|
// HACK: remap file, to clear ram
|
||||||
|
|
||||||
// TODO: error checking
|
// TODO: error checking
|
||||||
o.get<Message::Components::Transfer::File>() = std::make_unique<File2RWMapped>(
|
o.get<Message::Components::Transfer::File>() = construct_file2_rw_mapped(
|
||||||
o.get<Message::Components::Transfer::FileInfoLocal>().file_list.front(),
|
o.get<Message::Components::Transfer::FileInfoLocal>().file_list.front(),
|
||||||
info.file_size
|
info.file_size
|
||||||
);
|
);
|
||||||
@ -1185,7 +1185,7 @@ bool SHA1_NGCFT1::sendFilePath(const Contact3 c, std::string_view file_name, std
|
|||||||
file_name_ = std::string(file_name),
|
file_name_ = std::string(file_name),
|
||||||
file_path_ = std::string(file_path)
|
file_path_ = std::string(file_path)
|
||||||
]() mutable {
|
]() mutable {
|
||||||
auto file_impl = std::make_unique<File2RWMapped>(file_path_, -1);
|
std::unique_ptr<File2I> file_impl = construct_file2_rw_mapped(file_path_, -1);
|
||||||
if (!file_impl->isGood()) {
|
if (!file_impl->isGood()) {
|
||||||
{
|
{
|
||||||
std::lock_guard l{self->_info_builder_queue_mutex};
|
std::lock_guard l{self->_info_builder_queue_mutex};
|
||||||
@ -1235,7 +1235,7 @@ bool SHA1_NGCFT1::sendFilePath(const Contact3 c, std::string_view file_name, std
|
|||||||
]() mutable { //
|
]() mutable { //
|
||||||
// back on iterate thread
|
// back on iterate thread
|
||||||
|
|
||||||
auto file_impl = std::make_unique<File2RWMapped>(file_path_, sha1_info.file_size);
|
std::unique_ptr<File2I> file_impl = construct_file2_rw_mapped(file_path_, sha1_info.file_size);
|
||||||
if (!file_impl->isGood()) {
|
if (!file_impl->isGood()) {
|
||||||
std::cerr << "SHA1_NGCFT1 error: failed opening file '" << file_path_ << "'!\n";
|
std::cerr << "SHA1_NGCFT1 error: failed opening file '" << file_path_ << "'!\n";
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user