cleanup
This commit is contained in:
@ -45,9 +45,6 @@ public:
|
||||
[[nodiscard]] static auto
|
||||
default_rpc_port(const provider_type &prov) -> std::uint16_t;
|
||||
|
||||
[[nodiscard]] static auto
|
||||
get_provider_api_password(const provider_type &prov) -> std::string;
|
||||
|
||||
[[nodiscard]] static auto
|
||||
get_provider_display_name(const provider_type &prov) -> std::string;
|
||||
|
||||
|
@ -28,9 +28,6 @@
|
||||
namespace repertory::utils::file {
|
||||
void change_to_process_directory();
|
||||
|
||||
[[nodiscard]] auto copy_directory_recursively(std::string from_path,
|
||||
std::string to_path) -> bool;
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_directory_files(std::string path, bool oldest_first,
|
||||
bool recursive = false) -> std::deque<std::string>;
|
||||
@ -41,10 +38,6 @@ get_free_drive_space(const std::string &path) -> std::uint64_t;
|
||||
[[nodiscard]] auto
|
||||
get_total_drive_space(const std::string &path) -> std::uint64_t;
|
||||
|
||||
[[nodiscard]] auto
|
||||
is_modified_date_older_than(std::string_view path,
|
||||
const std::chrono::hours &hours) -> bool;
|
||||
|
||||
[[nodiscard]] auto
|
||||
read_file_lines(const std::string &path) -> std::vector<std::string>;
|
||||
|
||||
|
@ -325,34 +325,6 @@ auto app_config::get_max_cache_size_bytes() const -> std::uint64_t {
|
||||
max_space);
|
||||
}
|
||||
|
||||
auto app_config::get_provider_api_password(const provider_type &prov)
|
||||
-> std::string {
|
||||
#if defined(_WIN32)
|
||||
auto api_file = utils::path::combine(utils::get_local_app_data_directory(),
|
||||
{
|
||||
get_provider_display_name(prov),
|
||||
"apipassword",
|
||||
});
|
||||
#else
|
||||
#if defined(__APPLE__)
|
||||
auto api_file = utils::path::combine("~", {
|
||||
"/",
|
||||
"Library",
|
||||
"Application Support",
|
||||
get_provider_display_name(prov),
|
||||
"apipassword",
|
||||
});
|
||||
#else
|
||||
auto api_file = utils::path::combine("~/.", {
|
||||
get_provider_name(prov),
|
||||
"apipassword",
|
||||
});
|
||||
#endif
|
||||
#endif
|
||||
auto lines = utils::file::read_file_lines(api_file);
|
||||
return lines.empty() ? "" : utils::string::trim(lines[0U]);
|
||||
}
|
||||
|
||||
auto app_config::get_provider_display_name(const provider_type &prov)
|
||||
-> std::string {
|
||||
static const std::array<std::string,
|
||||
@ -605,13 +577,6 @@ auto app_config::load() -> bool {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
if (hc_.api_password.empty()) {
|
||||
hc_.api_password = get_provider_api_password(prov_);
|
||||
if (hc_.api_password.empty()) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (json_document.find("S3Config") != json_document.end()) {
|
||||
auto s3_config_json = json_document["S3Config"];
|
||||
auto s3_cfg = s3_config_;
|
||||
|
@ -54,61 +54,6 @@ void change_to_process_directory() {
|
||||
#endif
|
||||
}
|
||||
|
||||
auto copy_directory_recursively(std::string from_path,
|
||||
std::string to_path) -> bool {
|
||||
from_path = utils::path::absolute(from_path);
|
||||
to_path = utils::path::absolute(to_path);
|
||||
auto ret = utils::file::directory(to_path).create_directory() != nullptr;
|
||||
if (ret) {
|
||||
#if defined(_WIN32)
|
||||
WIN32_FIND_DATA fd{};
|
||||
const auto search = utils::path::combine(from_path, {"*.*"});
|
||||
auto find = ::FindFirstFile(search.c_str(), &fd);
|
||||
if (find != INVALID_HANDLE_VALUE) {
|
||||
ret = true;
|
||||
do {
|
||||
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
if ((std::string(fd.cFileName) != ".") &&
|
||||
(std::string(fd.cFileName) != "..")) {
|
||||
ret = copy_directory_recursively(
|
||||
utils::path::combine(from_path, {fd.cFileName}),
|
||||
utils::path::combine(to_path, {fd.cFileName}));
|
||||
}
|
||||
} else {
|
||||
ret =
|
||||
utils::file::file(utils::path::combine(from_path, {fd.cFileName}))
|
||||
.copy_to(utils::path::combine(to_path, {fd.cFileName}), true);
|
||||
}
|
||||
} while (ret && (::FindNextFile(find, &fd) != 0));
|
||||
|
||||
::FindClose(find);
|
||||
}
|
||||
#else
|
||||
auto *root = opendir(from_path.c_str());
|
||||
if (root) {
|
||||
struct dirent *de{};
|
||||
while (ret && (de = readdir(root))) {
|
||||
if (de->d_type == DT_DIR) {
|
||||
if ((strcmp(de->d_name, ".") != 0) &&
|
||||
(strcmp(de->d_name, "..") != 0)) {
|
||||
ret = copy_directory_recursively(
|
||||
utils::path::combine(from_path, {de->d_name}),
|
||||
utils::path::combine(to_path, {de->d_name}));
|
||||
}
|
||||
} else {
|
||||
ret = utils::file::file(utils::path::combine(from_path, {de->d_name}))
|
||||
.copy_to(utils::path::combine(to_path, {de->d_name}), true);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(root);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto get_free_drive_space(const std::string &path) -> std::uint64_t {
|
||||
#if defined(_WIN32)
|
||||
ULARGE_INTEGER li{};
|
||||
@ -230,15 +175,6 @@ auto get_directory_files(std::string path, bool oldest_first,
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto is_modified_date_older_than(std::string_view path,
|
||||
const std::chrono::hours &hours) -> bool {
|
||||
auto modified = file{path}.get_time(time_type::modified);
|
||||
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(hours);
|
||||
return (modified + static_cast<std::uint64_t>(seconds.count()) *
|
||||
utils::time::NANOS_PER_SECOND) <
|
||||
utils::time::get_time_now();
|
||||
}
|
||||
|
||||
auto read_file_lines(const std::string &path) -> std::vector<std::string> {
|
||||
std::vector<std::string> ret;
|
||||
if (utils::file::file(path).exists()) {
|
||||
|
Reference in New Issue
Block a user