Add macOS support #34
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit

This commit is contained in:
2025-08-01 14:12:27 +02:00
parent 1bbe078799
commit 81c6875382
6 changed files with 36 additions and 15 deletions

View File

@@ -35,13 +35,9 @@ list(APPEND PROJECT_CXXFLAGS_LIST
-Wcast-align -Wcast-align
-Wconversion -Wconversion
-Wdouble-promotion -Wdouble-promotion
-Wduplicated-branches
-Wduplicated-cond
-Wextra -Wextra
-Wformat=2 -Wformat=2
-Wlogical-op
-Wmisleading-indentation -Wmisleading-indentation
-Wno-useless-cast
-Wnon-virtual-dtor -Wnon-virtual-dtor
-Wnull-dereference -Wnull-dereference
-Wold-style-cast -Wold-style-cast
@@ -52,6 +48,15 @@ list(APPEND PROJECT_CXXFLAGS_LIST
-Wunused -Wunused
) )
if (NOT PROJECT_IS_DARWIN)
list(APPEND PROJECT_CXXFLAGS_LIST
-Wduplicated-branches
-Wduplicated-cond
-Wlogical-op
-Wno-useless-cast
)
endif()
list(APPEND PROJECT_CFLAGS_LIST list(APPEND PROJECT_CFLAGS_LIST
${PROJECT_COMMON_FLAG_LIST} ${PROJECT_COMMON_FLAG_LIST}
-std=c${CMAKE_C_STANDARD} -std=c${CMAKE_C_STANDARD}

View File

@@ -29,7 +29,7 @@
namespace repertory { namespace repertory {
class app_config; class app_config;
class i_file_manager; class i_file_manager;
class i_http_comm; struct i_http_comm;
class base_provider : public i_provider { class base_provider : public i_provider {
private: private:

View File

@@ -28,7 +28,7 @@
namespace repertory { namespace repertory {
class app_config; class app_config;
class i_file_manager; class i_file_manager;
class i_http_comm; struct i_http_comm;
struct head_object_result; struct head_object_result;
class s3_provider final : public base_provider { class s3_provider final : public base_provider {

View File

@@ -28,7 +28,7 @@
namespace repertory { namespace repertory {
class app_config; class app_config;
class i_file_manager; class i_file_manager;
class i_http_comm; struct i_http_comm;
class sia_provider : public base_provider { class sia_provider : public base_provider {
public: public:

View File

@@ -132,7 +132,9 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
config_->get_api_port()) config_->get_api_port())
.c_str()); .c_str());
#else // error #else // error
build fails here system(
fmt::format(R"(open "http://127.0.0.1:{}/ui")", config_->get_api_port())
.c_str());
#endif #endif
} }

View File

@@ -55,7 +55,8 @@ auto change_to_process_directory() -> bool {
std::string path; std::string path;
path.resize(PATH_MAX + 1); path.resize(PATH_MAX + 1);
#if defined(__APPLE__) #if defined(__APPLE__)
proc_pidpath(getpid(), path.c_str(), path.size()); proc_pidpath(getpid(), reinterpret_cast<void *>(path.data()),
static_cast<uint32_t>(path.size()));
#else // !defined(__APPLE__) #else // !defined(__APPLE__)
auto res = readlink("/proc/self/exe", path.data(), path.size()); auto res = readlink("/proc/self/exe", path.data(), path.size());
if (res == -1) { if (res == -1) {
@@ -68,7 +69,7 @@ auto change_to_process_directory() -> bool {
} }
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
path = utils::path::get_parent_path(path); path = utils::path::get_parent_path(path);
res = chdir(path.c_str()); auto res = chdir(path.c_str());
if (res != 0) { if (res != 0) {
throw utils::error::create_exception( throw utils::error::create_exception(
function_name, { function_name, {
@@ -148,7 +149,7 @@ auto get_free_drive_space(std::string_view path)
#if defined(__APPLE__) #if defined(__APPLE__)
struct statvfs st{}; struct statvfs st{};
if (statvfs(path.c_str(), &st) != 0) { if (statvfs(std::string{path}.c_str(), &st) != 0) {
throw utils::error::create_exception( throw utils::error::create_exception(
function_name, { function_name, {
"failed to get free disk space", "failed to get free disk space",
@@ -240,6 +241,20 @@ auto get_times(std::string_view path) -> std::optional<file_times> {
}); });
} }
#if defined(__APPLE__)
ret.accessed = static_cast<std::uint64_t>(st.st_atimespec.tv_nsec) +
static_cast<std::uint64_t>(st.st_atimespec.tv_sec) *
utils::time::NANOS_PER_SECOND;
ret.created = static_cast<std::uint64_t>(st.st_ctimespec.tv_nsec) +
static_cast<std::uint64_t>(st.st_ctimespec.tv_sec) *
utils::time::NANOS_PER_SECOND;
ret.modified = static_cast<std::uint64_t>(st.st_mtimespec.tv_nsec) +
static_cast<std::uint64_t>(st.st_mtimespec.tv_sec) *
utils::time::NANOS_PER_SECOND;
ret.written = static_cast<std::uint64_t>(st.st_mtimespec.tv_nsec) +
static_cast<std::uint64_t>(st.st_mtimespec.tv_sec) *
utils::time::NANOS_PER_SECOND;
#else // !defined(__APPLE__)
ret.accessed = static_cast<std::uint64_t>(st.st_atim.tv_nsec) + ret.accessed = static_cast<std::uint64_t>(st.st_atim.tv_nsec) +
static_cast<std::uint64_t>(st.st_atim.tv_sec) * static_cast<std::uint64_t>(st.st_atim.tv_sec) *
utils::time::NANOS_PER_SECOND; utils::time::NANOS_PER_SECOND;
@@ -252,7 +267,7 @@ auto get_times(std::string_view path) -> std::optional<file_times> {
ret.written = static_cast<std::uint64_t>(st.st_mtim.tv_nsec) + ret.written = static_cast<std::uint64_t>(st.st_mtim.tv_nsec) +
static_cast<std::uint64_t>(st.st_mtim.tv_sec) * static_cast<std::uint64_t>(st.st_mtim.tv_sec) *
utils::time::NANOS_PER_SECOND; utils::time::NANOS_PER_SECOND;
#endif // defined(__APPLE__)
#endif // defined(_WIN32) #endif // defined(_WIN32)
return ret; return ret;
@@ -305,7 +320,7 @@ auto get_total_drive_space(std::string_view path)
#if defined(__APPLE__) #if defined(__APPLE__)
struct statvfs st{}; struct statvfs st{};
if (statvfs(path.c_str(), &st) != 0) { if (statvfs(std::string{path}.c_str(), &st) != 0) {
throw utils::error::create_exception( throw utils::error::create_exception(
function_name, { function_name, {
"failed to get total disk space", "failed to get total disk space",
@@ -498,8 +513,7 @@ auto write_json_file(std::wstring_view path, const nlohmann::json &data)
#endif // defined(PROJECT_ENABLE_JSON) #endif // defined(PROJECT_ENABLE_JSON)
#if defined(PROJECT_ENABLE_LIBDSM) #if defined(PROJECT_ENABLE_LIBDSM)
static constexpr auto validate_smb_path = static constexpr auto validate_smb_path = [](std::string_view path) -> bool {
[](std::string_view path) -> bool {
return (not utils::string::begins_with(path, "///") && return (not utils::string::begins_with(path, "///") &&
utils::string::begins_with(path, "//") && utils::string::begins_with(path, "//") &&
// not utils::string::contains(path, " ") && // not utils::string::contains(path, " ") &&