updated build system
Some checks failed
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
Some checks failed
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "utils/common.hpp"
|
||||
#include "utils/error.hpp"
|
||||
#include "utils/string.hpp"
|
||||
#include "utils/unix.hpp"
|
||||
#include "utils/windows.hpp"
|
||||
|
||||
@@ -32,6 +33,8 @@ auto traverse_directory(
|
||||
std::function<bool(repertory::utils::file::directory)> directory_action,
|
||||
std::function<bool(repertory::utils::file::file)> file_action,
|
||||
repertory::stop_type *stop_requested) -> bool {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
auto res{true};
|
||||
|
||||
const auto is_stop_requested = [&stop_requested]() -> bool {
|
||||
@@ -43,9 +46,12 @@ auto traverse_directory(
|
||||
auto search = repertory::utils::path::combine(path, {"*.*"});
|
||||
auto find = ::FindFirstFileA(search.c_str(), &fd);
|
||||
if (find == INVALID_HANDLE_VALUE) {
|
||||
throw std::runtime_error(
|
||||
"failed to open directory|" + std::string{path} + '|' +
|
||||
std::to_string(repertory::utils::get_last_error_code()));
|
||||
throw repertory::utils::error::create_exception({
|
||||
function_name,
|
||||
"failed to open directory",
|
||||
std::to_string(repertory::utils::get_last_error_code()),
|
||||
path,
|
||||
});
|
||||
}
|
||||
|
||||
do {
|
||||
@@ -67,9 +73,12 @@ auto traverse_directory(
|
||||
#else // !defined(_WIN32)
|
||||
auto *root = opendir(std::string{path}.c_str());
|
||||
if (root == nullptr) {
|
||||
throw std::runtime_error(
|
||||
"failed to open directory|" + std::string{path} + '|' +
|
||||
std::to_string(repertory::utils::get_last_error_code()));
|
||||
throw repertory::utils::error::create_exception({
|
||||
function_name,
|
||||
"failed to open directory",
|
||||
std::to_string(repertory::utils::get_last_error_code()),
|
||||
path,
|
||||
});
|
||||
}
|
||||
|
||||
struct dirent *de{nullptr};
|
||||
@@ -94,14 +103,19 @@ auto traverse_directory(
|
||||
} // namespace
|
||||
|
||||
namespace repertory::utils::file {
|
||||
auto directory::copy_to(std::string_view new_path, bool overwrite) const
|
||||
-> bool {
|
||||
auto directory::copy_to(std::string_view new_path,
|
||||
bool overwrite) const -> bool {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
throw std::runtime_error("failed to copy directory|" + path_ + '|' +
|
||||
std::string{new_path} + '+' +
|
||||
std::to_string(overwrite) + "|not implemented");
|
||||
throw utils::error::create_exception({
|
||||
function_name,
|
||||
"failed to copy directory",
|
||||
"not implemented",
|
||||
path_,
|
||||
new_path,
|
||||
utils::string::from_bool(overwrite),
|
||||
});
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::handle_exception(function_name, e);
|
||||
} catch (...) {
|
||||
@@ -157,11 +171,14 @@ auto directory::create_directory(std::string_view path) const
|
||||
auto res = ::SHCreateDirectory(nullptr,
|
||||
utils::string::from_utf8(abs_path).c_str());
|
||||
if (res != ERROR_SUCCESS) {
|
||||
throw std::runtime_error("failed to create directory|" +
|
||||
std::string{abs_path} + '|' +
|
||||
std::to_string(res));
|
||||
throw utils::error::create_exception({
|
||||
function_name,
|
||||
"failed to create directory",
|
||||
std::to_string(res),
|
||||
abs_path,
|
||||
});
|
||||
}
|
||||
#else // !defined(_WIN32)
|
||||
#else // !defined(_WIN32)
|
||||
auto ret{true};
|
||||
auto paths =
|
||||
utils::string::split(abs_path, utils::path::directory_seperator, false);
|
||||
@@ -194,7 +211,7 @@ auto directory::exists() const -> bool {
|
||||
#if defined(_WIN32)
|
||||
return ::PathIsDirectoryA(path_.c_str()) != 0;
|
||||
#else // !defined(_WIN32)
|
||||
struct stat64 st{};
|
||||
struct stat64 st {};
|
||||
return (stat64(path_.c_str(), &st) == 0 && S_ISDIR(st.st_mode));
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
@@ -247,8 +264,8 @@ auto directory::get_directories() const -> std::vector<fs_directory_t> {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto directory::create_file(std::string_view file_name, bool read_only) const
|
||||
-> fs_file_t {
|
||||
auto directory::create_file(std::string_view file_name,
|
||||
bool read_only) const -> fs_file_t {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
@@ -360,8 +377,13 @@ auto directory::move_to(std::string_view new_path) -> bool {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
try {
|
||||
throw std::runtime_error("failed to move directory|" + path_ + '|' +
|
||||
std::string{new_path} + "|not implemented");
|
||||
throw utils::error::create_exception({
|
||||
function_name,
|
||||
"failed to move directory",
|
||||
"not implemented",
|
||||
path_,
|
||||
new_path,
|
||||
});
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::handle_exception(function_name, e);
|
||||
} catch (...) {
|
||||
@@ -383,7 +405,10 @@ auto directory::remove() -> bool {
|
||||
#endif // defined(_WIN32)
|
||||
if (not ret) {
|
||||
utils::error::handle_error(function_name,
|
||||
"failed to remove directory|" + path_);
|
||||
utils::error::create_error_message({
|
||||
"failed to remove directory",
|
||||
path_,
|
||||
}));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user