From c0be6765ab88092e843990067300b977b9cbb853 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Fri, 23 Aug 2024 16:54:00 -0500 Subject: [PATCH] updated build system --- support/include/utils/time.hpp | 2 ++ support/src/utils/file_directory.cpp | 8 ++++---- support/src/utils/time.cpp | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/support/include/utils/time.hpp b/support/include/utils/time.hpp index e5460e67..7a7bd688 100644 --- a/support/include/utils/time.hpp +++ b/support/include/utils/time.hpp @@ -55,6 +55,8 @@ void get_local_time_now(struct tm &local_time); #if defined(_WIN32) auto strptime(const char *s, const char *f, struct tm *tm) -> const char *; +[[nodiscard]] auto time64_to_unix_time(const __time64_t &time) -> std::uint64_t; + [[nodiscard]] auto unix_time_to_filetime(std::uint64_t unix_time) -> FILETIME; #endif // defined(_WIN32) diff --git a/support/src/utils/file_directory.cpp b/support/src/utils/file_directory.cpp index 61ac0508..cf418063 100644 --- a/support/src/utils/file_directory.cpp +++ b/support/src/utils/file_directory.cpp @@ -58,11 +58,11 @@ auto traverse_directory( ::FindClose(find); #else // !defined(_WIN32) - auto *root = opendir(path.c_str()); + 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(utils::get_last_error_code())); + throw std::runtime_error( + "failed to open directory|" + std::string{path} + '|' + + std::to_string(repertory::utils::get_last_error_code())); } struct dirent *de{}; diff --git a/support/src/utils/time.cpp b/support/src/utils/time.cpp index c706d7cc..cc11ca04 100644 --- a/support/src/utils/time.cpp +++ b/support/src/utils/time.cpp @@ -66,6 +66,10 @@ auto strptime(const char *s, const char *f, struct tm *tm) -> const char * { return reinterpret_cast(s + input.tellg()); } +auto time64_to_unix_time(const __time64_t &time) -> std::uint64_t { + return static_cast(time * NANOS_PER_SECOND); +} + // https://www.frenk.com/2009/12/convert-filetime-to-unix-timestamp/ auto unix_time_to_filetime(std::uint64_t unix_time) -> FILETIME { auto win_time =