updated build system

This commit is contained in:
2024-08-23 12:35:48 -05:00
parent c8929fed0b
commit f654d269a7
8 changed files with 36 additions and 55 deletions

View File

@ -25,7 +25,7 @@
#include "utils/config.hpp"
namespace repertory::utils::time {
inline constexpr const auto NANOS_PER_SECOND = 1000000000L;
inline constexpr const auto NANOS_PER_SECOND{1000000000ULL};
inline constexpr const auto WIN32_TIME_CONVERSION{116444736000000000ULL};
inline constexpr const auto WIN32_TIME_NANOS_PER_TICK{100ULL};
@ -55,8 +55,6 @@ 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)

View File

@ -75,7 +75,8 @@ auto i_fs_item::get_time(time_types type) const -> std::uint64_t {
switch (type) {
case time_types::access:
#if defined(_WIN32)
return static_cast<std::uint64_t>(st.st_atime);
return utils::time::windows_time_to_unix_time(
static_cast<std::uint64_t>(st.st_atime));
#else // !defined(_WIN32)
return static_cast<std::uint64_t>(st.st_atim.tv_nsec +
st.st_atim.tv_sec *
@ -84,7 +85,8 @@ auto i_fs_item::get_time(time_types type) const -> std::uint64_t {
case time_types::creation:
#if defined(_WIN32)
return static_cast<std::uint64_t>(st.st_ctime);
return utils::time::windows_time_to_unix_time(
static_cast<std::uint64_t>(st.st_ctime));
#else // !defined(_WIN32)
return static_cast<std::uint64_t>(st.st_ctim.tv_nsec +
st.st_ctim.tv_sec *
@ -93,7 +95,8 @@ auto i_fs_item::get_time(time_types type) const -> std::uint64_t {
case time_types::modified:
#if defined(_WIN32)
return static_cast<std::uint64_t>(st.st_mtime);
return utils::time::windows_time_to_unix_time(
static_cast<std::uint64_t>(st.st_mtime));
#else // !defined(_WIN32)
return static_cast<std::uint64_t>(st.st_mtim.tv_nsec +
st.st_mtim.tv_sec *
@ -102,7 +105,8 @@ auto i_fs_item::get_time(time_types type) const -> std::uint64_t {
case time_types::write:
#if defined(_WIN32)
return static_cast<std::uint64_t>(st.st_mtime);
return utils::time::windows_time_to_unix_time(
static_cast<std::uint64_t>(st.st_mtime));
#else // !defined(_WIN32)
return static_cast<std::uint64_t>(st.st_mtim.tv_nsec +
st.st_mtim.tv_sec *

View File

@ -66,10 +66,6 @@ auto strptime(const char *s, const char *f, struct tm *tm) -> const char * {
return reinterpret_cast<const char *>(s + input.tellg());
}
auto time64_to_unix_time(const __time64_t &time) -> std::uint64_t {
return static_cast<std::uint64_t>(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 =