Add macOS support #34
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -35,13 +35,9 @@ list(APPEND PROJECT_CXXFLAGS_LIST
|
||||
-Wcast-align
|
||||
-Wconversion
|
||||
-Wdouble-promotion
|
||||
-Wduplicated-branches
|
||||
-Wduplicated-cond
|
||||
-Wextra
|
||||
-Wformat=2
|
||||
-Wlogical-op
|
||||
-Wmisleading-indentation
|
||||
-Wno-useless-cast
|
||||
-Wnon-virtual-dtor
|
||||
-Wnull-dereference
|
||||
-Wold-style-cast
|
||||
@@ -52,6 +48,15 @@ list(APPEND PROJECT_CXXFLAGS_LIST
|
||||
-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
|
||||
${PROJECT_COMMON_FLAG_LIST}
|
||||
-std=c${CMAKE_C_STANDARD}
|
||||
|
@@ -29,7 +29,7 @@
|
||||
namespace repertory {
|
||||
class app_config;
|
||||
class i_file_manager;
|
||||
class i_http_comm;
|
||||
struct i_http_comm;
|
||||
|
||||
class base_provider : public i_provider {
|
||||
private:
|
||||
|
@@ -28,7 +28,7 @@
|
||||
namespace repertory {
|
||||
class app_config;
|
||||
class i_file_manager;
|
||||
class i_http_comm;
|
||||
struct i_http_comm;
|
||||
struct head_object_result;
|
||||
|
||||
class s3_provider final : public base_provider {
|
||||
|
@@ -28,7 +28,7 @@
|
||||
namespace repertory {
|
||||
class app_config;
|
||||
class i_file_manager;
|
||||
class i_http_comm;
|
||||
struct i_http_comm;
|
||||
|
||||
class sia_provider : public base_provider {
|
||||
public:
|
||||
|
@@ -132,7 +132,9 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
|
||||
config_->get_api_port())
|
||||
.c_str());
|
||||
#else // error
|
||||
build fails here
|
||||
system(
|
||||
fmt::format(R"(open "http://127.0.0.1:{}/ui")", config_->get_api_port())
|
||||
.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -55,7 +55,8 @@ auto change_to_process_directory() -> bool {
|
||||
std::string path;
|
||||
path.resize(PATH_MAX + 1);
|
||||
#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__)
|
||||
auto res = readlink("/proc/self/exe", path.data(), path.size());
|
||||
if (res == -1) {
|
||||
@@ -68,7 +69,7 @@ auto change_to_process_directory() -> bool {
|
||||
}
|
||||
#endif // defined(__APPLE__)
|
||||
path = utils::path::get_parent_path(path);
|
||||
res = chdir(path.c_str());
|
||||
auto res = chdir(path.c_str());
|
||||
if (res != 0) {
|
||||
throw utils::error::create_exception(
|
||||
function_name, {
|
||||
@@ -148,7 +149,7 @@ auto get_free_drive_space(std::string_view path)
|
||||
|
||||
#if defined(__APPLE__)
|
||||
struct statvfs st{};
|
||||
if (statvfs(path.c_str(), &st) != 0) {
|
||||
if (statvfs(std::string{path}.c_str(), &st) != 0) {
|
||||
throw utils::error::create_exception(
|
||||
function_name, {
|
||||
"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) +
|
||||
static_cast<std::uint64_t>(st.st_atim.tv_sec) *
|
||||
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) +
|
||||
static_cast<std::uint64_t>(st.st_mtim.tv_sec) *
|
||||
utils::time::NANOS_PER_SECOND;
|
||||
|
||||
#endif // defined(__APPLE__)
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
return ret;
|
||||
@@ -305,7 +320,7 @@ auto get_total_drive_space(std::string_view path)
|
||||
|
||||
#if defined(__APPLE__)
|
||||
struct statvfs st{};
|
||||
if (statvfs(path.c_str(), &st) != 0) {
|
||||
if (statvfs(std::string{path}.c_str(), &st) != 0) {
|
||||
throw utils::error::create_exception(
|
||||
function_name, {
|
||||
"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)
|
||||
|
||||
#if defined(PROJECT_ENABLE_LIBDSM)
|
||||
static constexpr auto validate_smb_path =
|
||||
[](std::string_view path) -> bool {
|
||||
static constexpr auto validate_smb_path = [](std::string_view path) -> bool {
|
||||
return (not utils::string::begins_with(path, "///") &&
|
||||
utils::string::begins_with(path, "//") &&
|
||||
// not utils::string::contains(path, " ") &&
|
||||
|
Reference in New Issue
Block a user