revert
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,6 +26,9 @@
|
||||
#include "utils/encrypting_reader.hpp"
|
||||
|
||||
namespace repertory::utils::encryption {
|
||||
using reader_func = std::function<api_error(data_buffer &cypher_text,
|
||||
std::uint64_t start_offset,
|
||||
std::uint64_t end_offset)>;
|
||||
// Prototypes
|
||||
[[nodiscard]] auto decrypt_file_path(const std::string &encryption_token,
|
||||
std::string &file_path) -> api_error;
|
||||
@@ -36,11 +39,10 @@ namespace repertory::utils::encryption {
|
||||
[[nodiscard]] auto generate_key(const std::string &encryption_token)
|
||||
-> key_type;
|
||||
|
||||
[[nodiscard]] auto read_encrypted_range(
|
||||
const http_range &range, const key_type &key,
|
||||
const std::function<api_error(data_buffer &ct, std::uint64_t start_offset,
|
||||
std::uint64_t end_offset)> &reader,
|
||||
std::uint64_t total_size, data_buffer &data) -> api_error;
|
||||
[[nodiscard]] auto read_encrypted_range(const http_range &range,
|
||||
const key_type &key, reader_func reader,
|
||||
std::uint64_t total_size,
|
||||
data_buffer &data) -> api_error;
|
||||
|
||||
// Implementations
|
||||
template <typename result>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,60 +25,60 @@
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
namespace repertory::utils::error {
|
||||
void raise_error(std::string_view function, std::string_view msg);
|
||||
void raise_error(std::string function, std::string_view msg);
|
||||
|
||||
void raise_error(std::string_view function, const api_error &e,
|
||||
void raise_error(std::string function, const api_error &err,
|
||||
std::string_view msg);
|
||||
|
||||
void raise_error(std::string_view function, const std::exception &e,
|
||||
void raise_error(std::string function, const std::exception &exception,
|
||||
std::string_view msg);
|
||||
|
||||
void raise_error(std::string_view function, std::int64_t e,
|
||||
std::string_view msg);
|
||||
void raise_error(std::string function, std::int64_t err, std::string_view msg);
|
||||
|
||||
void raise_error(std::string_view function, const json &e,
|
||||
std::string_view msg);
|
||||
void raise_error(std::string function, const json &err, std::string_view msg);
|
||||
|
||||
void raise_error(std::string_view function, const api_error &e,
|
||||
void raise_error(std::string function, const api_error &err,
|
||||
std::string_view file_path, std::string_view msg);
|
||||
|
||||
void raise_error(std::string_view function, std::int64_t e,
|
||||
void raise_error(std::string function, std::int64_t err,
|
||||
std::string_view file_path, std::string_view msg);
|
||||
|
||||
void raise_error(std::string_view function, const std::exception &e,
|
||||
void raise_error(std::string function, const std::exception &exception,
|
||||
std::string_view file_path, std::string_view msg);
|
||||
|
||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||
const api_error &e, std::string_view msg);
|
||||
void raise_api_path_error(std::string function, std::string_view api_path,
|
||||
const api_error &err, std::string_view msg);
|
||||
|
||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||
const std::exception &e, std::string_view msg);
|
||||
|
||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||
std::int64_t e, std::string_view msg);
|
||||
|
||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||
const json &e, std::string_view msg);
|
||||
|
||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||
std::string_view source_path, const api_error &e,
|
||||
void raise_api_path_error(std::string function, std::string_view api_path,
|
||||
const std::exception &exception,
|
||||
std::string_view msg);
|
||||
|
||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||
std::string_view source_path, std::int64_t e,
|
||||
void raise_api_path_error(std::string function, std::string_view api_path,
|
||||
std::int64_t err, std::string_view msg);
|
||||
|
||||
void raise_api_path_error(std::string function, std::string_view api_path,
|
||||
const json &err, std::string_view msg);
|
||||
|
||||
void raise_api_path_error(std::string function, std::string_view api_path,
|
||||
std::string_view source_path, const api_error &err,
|
||||
std::string_view msg);
|
||||
|
||||
void raise_api_path_error(std::string_view function, std::string_view api_path,
|
||||
std::string_view source_path, const std::exception &e,
|
||||
void raise_api_path_error(std::string function, std::string_view api_path,
|
||||
std::string_view source_path, std::int64_t err,
|
||||
std::string_view msg);
|
||||
|
||||
void raise_url_error(std::string_view function, std::string_view url,
|
||||
CURLcode e, std::string_view msg);
|
||||
void raise_api_path_error(std::string function, std::string_view api_path,
|
||||
std::string_view source_path,
|
||||
const std::exception &exception,
|
||||
std::string_view msg);
|
||||
|
||||
void raise_url_error(std::string_view function, std::string_view url,
|
||||
std::string_view source_path, const std::exception &e,
|
||||
void raise_url_error(std::string function, std::string_view url, CURLcode err,
|
||||
std::string_view msg);
|
||||
|
||||
void raise_url_error(std::string function, std::string_view url,
|
||||
std::string_view source_path,
|
||||
const std::exception &exception, std::string_view msg);
|
||||
|
||||
} // namespace repertory::utils::error
|
||||
|
||||
#endif // INCLUDE_UTILS_ERROR_UTILS_HPP_
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -27,6 +27,11 @@
|
||||
namespace repertory {
|
||||
class native_file final {
|
||||
public:
|
||||
native_file(const native_file &) = delete;
|
||||
native_file(native_file &&) = delete;
|
||||
auto operator=(const native_file &) -> native_file & = delete;
|
||||
auto operator=(native_file &&) -> native_file & = delete;
|
||||
|
||||
using native_file_ptr = std::shared_ptr<native_file>;
|
||||
|
||||
public:
|
||||
@@ -34,22 +39,21 @@ public:
|
||||
return std::shared_ptr<native_file>(new native_file(handle));
|
||||
}
|
||||
|
||||
[[nodiscard]] static auto clone(const native_file_ptr &nativeFile)
|
||||
[[nodiscard]] static auto clone(const native_file_ptr &ptr)
|
||||
-> native_file_ptr;
|
||||
|
||||
[[nodiscard]] static auto create_or_open(const std::string &source_path,
|
||||
bool should_chmod,
|
||||
native_file_ptr &nf) -> api_error;
|
||||
bool read_only, native_file_ptr &ptr)
|
||||
-> api_error;
|
||||
|
||||
[[nodiscard]] static auto create_or_open(const std::string &source_path,
|
||||
native_file_ptr &nf) -> api_error;
|
||||
native_file_ptr &ptr) -> api_error;
|
||||
|
||||
[[nodiscard]] static auto open(const std::string &source_path,
|
||||
native_file_ptr &nf) -> api_error;
|
||||
native_file_ptr &ptr) -> api_error;
|
||||
|
||||
[[nodiscard]] static auto open(const std::string &source_path,
|
||||
bool should_chmod, native_file_ptr &nf)
|
||||
-> api_error;
|
||||
[[nodiscard]] static auto open(const std::string &source_path, bool read_only,
|
||||
native_file_ptr &ptr) -> api_error;
|
||||
|
||||
private:
|
||||
explicit native_file(const native_handle &handle) : handle_(handle) {}
|
||||
@@ -71,7 +75,7 @@ public:
|
||||
|
||||
void close();
|
||||
|
||||
[[nodiscard]] auto copy_from(const native_file_ptr &source) -> bool;
|
||||
[[nodiscard]] auto copy_from(const native_file_ptr &ptr) -> bool;
|
||||
|
||||
[[nodiscard]] auto copy_from(const std::string &path) -> bool;
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -22,15 +22,10 @@
|
||||
#ifndef INCLUDE_UTILS_STRING_UTILS_HPP_
|
||||
#define INCLUDE_UTILS_STRING_UTILS_HPP_
|
||||
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace repertory::utils::string {
|
||||
// Prototypes
|
||||
constexpr auto begins_with(std::string_view str, std::string_view val) -> bool {
|
||||
return (str.find(val) == 0u);
|
||||
return (str.find(val) == 0U);
|
||||
}
|
||||
|
||||
constexpr auto contains(std::string_view str, std::string_view search) -> bool {
|
||||
@@ -48,14 +43,15 @@ constexpr auto contains(std::string_view str, std::string_view search) -> bool {
|
||||
|
||||
[[nodiscard]] auto from_utf8(const std::string &str) -> std::wstring;
|
||||
|
||||
[[nodiscard]] /* constexpr c++20 */ auto is_numeric(std::string_view s) -> bool;
|
||||
[[nodiscard]] /* constexpr c++20 */ auto is_numeric(std::string_view str)
|
||||
-> bool;
|
||||
|
||||
[[nodiscard]] auto join(const std::vector<std::string> &arr, const char &delim)
|
||||
-> std::string;
|
||||
|
||||
auto left_trim(std::string &s) -> std::string &;
|
||||
auto left_trim(std::string &str) -> std::string &;
|
||||
|
||||
auto left_trim(std::string &s, const char &c) -> std::string &;
|
||||
auto left_trim(std::string &str, const char &trim_ch) -> std::string &;
|
||||
|
||||
auto replace(std::string &src, const char &character, const char &with)
|
||||
-> std::string &;
|
||||
@@ -70,9 +66,9 @@ auto replace(std::string &src, const std::string &find, const std::string &with,
|
||||
const std::string &with, size_t start_pos = 0)
|
||||
-> std::string;
|
||||
|
||||
auto right_trim(std::string &s) -> std::string &;
|
||||
auto right_trim(std::string &str) -> std::string &;
|
||||
|
||||
auto right_trim(std::string &s, const char &c) -> std::string &;
|
||||
auto right_trim(std::string &str, const char &trim_ch) -> std::string &;
|
||||
|
||||
[[nodiscard]] auto split(const std::string &str, const char &delim,
|
||||
bool should_trim = true) -> std::vector<std::string>;
|
||||
@@ -108,11 +104,12 @@ auto right_trim(std::string &s, const char &c) -> std::string &;
|
||||
|
||||
auto trim(std::string &str) -> std::string &;
|
||||
|
||||
auto trim(std::string &str, const char &c) -> std::string &;
|
||||
auto trim(std::string &str, const char &trim_ch) -> std::string &;
|
||||
|
||||
[[nodiscard]] auto trim_copy(std::string str) -> std::string;
|
||||
|
||||
[[nodiscard]] auto trim_copy(std::string str, const char &c) -> std::string;
|
||||
[[nodiscard]] auto trim_copy(std::string str, const char &trim_ch)
|
||||
-> std::string;
|
||||
} // namespace repertory::utils::string
|
||||
|
||||
#endif // INCLUDE_UTILS_STRING_UTILS_HPP_
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
namespace repertory::utils {
|
||||
#if __linux__
|
||||
inline const std::array<std::string, 4u> attribute_namespaces = {
|
||||
inline const std::array<std::string, 4U> attribute_namespaces = {
|
||||
"security",
|
||||
"system",
|
||||
"trusted",
|
||||
@@ -38,12 +38,12 @@ inline const std::array<std::string, 4u> attribute_namespaces = {
|
||||
|
||||
#if __APPLE__
|
||||
template <typename t>
|
||||
[[nodiscard]] auto convert_to_uint64(const t *v) -> std::uint64_t;
|
||||
[[nodiscard]] auto convert_to_uint64(const t *ptr) -> std::uint64_t;
|
||||
#else
|
||||
[[nodiscard]] auto convert_to_uint64(const pthread_t &t) -> std::uint64_t;
|
||||
[[nodiscard]] auto convert_to_uint64(const pthread_t &thread) -> std::uint64_t;
|
||||
#endif
|
||||
|
||||
[[nodiscard]] auto from_api_error(const api_error &e) -> int;
|
||||
[[nodiscard]] auto from_api_error(const api_error &err) -> int;
|
||||
|
||||
[[nodiscard]] auto get_last_error_code() -> int;
|
||||
|
||||
@@ -54,20 +54,20 @@ template <typename t>
|
||||
|
||||
void set_last_error_code(int error_code);
|
||||
|
||||
[[nodiscard]] auto to_api_error(int e) -> api_error;
|
||||
[[nodiscard]] auto to_api_error(int err) -> api_error;
|
||||
|
||||
[[nodiscard]] auto unix_error_to_windows(int e) -> std::int32_t;
|
||||
[[nodiscard]] auto unix_error_to_windows(int err) -> std::int32_t;
|
||||
|
||||
[[nodiscard]] auto unix_time_to_windows_time(const remote::file_time &ts)
|
||||
[[nodiscard]] auto unix_time_to_windows_time(const remote::file_time &file_time)
|
||||
-> UINT64;
|
||||
|
||||
void use_getpwuid(uid_t uid, std::function<void(struct passwd *pw)> fn);
|
||||
void use_getpwuid(uid_t uid, std::function<void(struct passwd *pass)> callback);
|
||||
|
||||
void windows_create_to_unix(const UINT32 &create_options,
|
||||
const UINT32 &granted_access, std::uint32_t &flags,
|
||||
remote::file_mode &mode);
|
||||
|
||||
[[nodiscard]] auto windows_time_to_unix_time(std::uint64_t t)
|
||||
[[nodiscard]] auto windows_time_to_unix_time(std::uint64_t win_time)
|
||||
-> remote::file_time;
|
||||
|
||||
// template implementations
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -151,7 +151,7 @@ template <typename t>
|
||||
template <typename data_type>
|
||||
[[nodiscard]] auto random_between(const data_type &begin, const data_type &end)
|
||||
-> data_type {
|
||||
return begin + repertory_rand<data_type>() % ((end + 1) - begin);
|
||||
return begin + repertory_rand<data_type>() % ((end + data_type{1}) - begin);
|
||||
}
|
||||
|
||||
template <typename collection_t>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
Reference in New Issue
Block a user