fixes
This commit is contained in:
@ -934,7 +934,7 @@ TEST(remote_fuse, all_tests) {
|
|||||||
|
|
||||||
event_system::instance().start();
|
event_system::instance().start();
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mount_location_ = std::string(test::get_test_output_dir(), 2);
|
mount_location_ = test::get_test_output_dir().substr(0, 2);
|
||||||
mock_winfsp_drive drive(mount_location_);
|
mock_winfsp_drive drive(mount_location_);
|
||||||
remote_server server(config, drive, mount_location_);
|
remote_server server(config, drive, mount_location_);
|
||||||
#else
|
#else
|
||||||
|
@ -491,7 +491,6 @@ TEST(remote_winfsp, all_tests) {
|
|||||||
EXPECT_TRUE(found_port);
|
EXPECT_TRUE(found_port);
|
||||||
if (found_port) {
|
if (found_port) {
|
||||||
console_consumer c;
|
console_consumer c;
|
||||||
|
|
||||||
app_config config(provider_type::remote, win_remote_dir);
|
app_config config(provider_type::remote, win_remote_dir);
|
||||||
config.set_remote_host_name_or_ip("localhost");
|
config.set_remote_host_name_or_ip("localhost");
|
||||||
config.set_remote_port(port);
|
config.set_remote_port(port);
|
||||||
@ -501,7 +500,7 @@ TEST(remote_winfsp, all_tests) {
|
|||||||
|
|
||||||
event_system::instance().start();
|
event_system::instance().start();
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mount_location_ = std::string(test::get_test_output_dir(), 2);
|
mount_location_ = test::get_test_output_dir().substr(0, 2);
|
||||||
mock_winfsp_drive drive(mount_location_);
|
mock_winfsp_drive drive(mount_location_);
|
||||||
remote_server server(config, drive, mount_location_);
|
remote_server server(config, drive, mount_location_);
|
||||||
#else
|
#else
|
||||||
|
@ -33,6 +33,7 @@ public:
|
|||||||
[[nodiscard]] static auto open_or_create_file(std::filesystem::path path,
|
[[nodiscard]] static auto open_or_create_file(std::filesystem::path path,
|
||||||
bool read_only = false) -> file;
|
bool read_only = false) -> file;
|
||||||
|
|
||||||
|
public:
|
||||||
file() noexcept = default;
|
file() noexcept = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -28,6 +28,11 @@
|
|||||||
|
|
||||||
namespace repertory::utils::file {
|
namespace repertory::utils::file {
|
||||||
auto file::open_file(std::filesystem::path path, bool read_only) -> file {
|
auto file::open_file(std::filesystem::path path, bool read_only) -> file {
|
||||||
|
static constexpr const std::string_view function_name{
|
||||||
|
static_cast<const char *>(__FUNCTION__),
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
path = utils::path::absolute(path.string());
|
path = utils::path::absolute(path.string());
|
||||||
if (not is_file(path.string())) {
|
if (not is_file(path.string())) {
|
||||||
throw std::runtime_error("file not found: " + path.string());
|
throw std::runtime_error("file not found: " + path.string());
|
||||||
@ -44,7 +49,6 @@ auto file::open_file(std::filesystem::path path, bool read_only) -> file {
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
auto *ptr =
|
auto *ptr =
|
||||||
_fsopen(path.string().c_str(), read_only ? "rb" : "rb+", _SH_DENYNO);
|
_fsopen(path.string().c_str(), read_only ? "rb" : "rb+", _SH_DENYNO);
|
||||||
std::cout << errno << std::endl;
|
|
||||||
#else // !defined(_WIN32)
|
#else // !defined(_WIN32)
|
||||||
auto *ptr = fopen(path.string().c_str(), read_only ? "rb" : "rb+");
|
auto *ptr = fopen(path.string().c_str(), read_only ? "rb" : "rb+");
|
||||||
#endif // defined(_WIN32)
|
#endif // defined(_WIN32)
|
||||||
@ -53,6 +57,13 @@ auto file::open_file(std::filesystem::path path, bool read_only) -> file {
|
|||||||
file_t{ptr},
|
file_t{ptr},
|
||||||
path,
|
path,
|
||||||
};
|
};
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
utils::error::handle_exception(function_name, e);
|
||||||
|
} catch (...) {
|
||||||
|
utils::error::handle_exception(function_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto file::open_or_create_file(std::filesystem::path path,
|
auto file::open_or_create_file(std::filesystem::path path,
|
||||||
|
@ -34,21 +34,23 @@ using namespace ::testing;
|
|||||||
|
|
||||||
#define COMMA ,
|
#define COMMA ,
|
||||||
|
|
||||||
#include "utils/config.hpp"
|
|
||||||
|
|
||||||
#include "utils/all.hpp"
|
#include "utils/all.hpp"
|
||||||
|
|
||||||
namespace repertory::test {
|
namespace repertory::test {
|
||||||
|
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||||
[[nodiscard]] auto create_random_file(std::size_t size) -> utils::file::file;
|
[[nodiscard]] auto create_random_file(std::size_t size) -> utils::file::file;
|
||||||
|
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||||
|
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto
|
||||||
generate_test_file_name(std::string_view file_name_no_extension) -> std::string;
|
generate_test_file_name(std::string_view file_name_no_extension) -> std::string;
|
||||||
|
|
||||||
|
#if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
|
||||||
template <typename buffer_t, typename result_t>
|
template <typename buffer_t, typename result_t>
|
||||||
static void decrypt_and_verify(const buffer_t &buffer, std::string_view token,
|
static void decrypt_and_verify(const buffer_t &buffer, std::string_view token,
|
||||||
result_t &result) {
|
result_t &result) {
|
||||||
EXPECT_TRUE(utils::encryption::decrypt_data(token, buffer, result));
|
EXPECT_TRUE(utils::encryption::decrypt_data(token, buffer, result));
|
||||||
}
|
}
|
||||||
|
#endif // defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
|
||||||
|
|
||||||
[[nodiscard]] auto get_test_input_dir() -> std::string;
|
[[nodiscard]] auto get_test_input_dir() -> std::string;
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ static auto deleter{std::make_unique<file_deleter>()};
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace repertory::test {
|
namespace repertory::test {
|
||||||
|
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||||
auto create_random_file(std::size_t size) -> utils::file::file {
|
auto create_random_file(std::size_t size) -> utils::file::file {
|
||||||
recur_mutex_lock lock{file_mtx};
|
recur_mutex_lock lock{file_mtx};
|
||||||
|
|
||||||
@ -74,6 +75,7 @@ auto create_random_file(std::size_t size) -> utils::file::file {
|
|||||||
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||||
|
|
||||||
auto generate_test_file_name(std::string_view file_name_no_extension)
|
auto generate_test_file_name(std::string_view file_name_no_extension)
|
||||||
-> std::string {
|
-> std::string {
|
||||||
|
Reference in New Issue
Block a user