updated build system
This commit is contained in:
@ -314,7 +314,7 @@ void remote_fuse_drive::populate_stat(const remote::stat &r_stat,
|
|||||||
unix_st.st_mtimespec.tv_sec = r_stat.st_mtimespec / NANOS_PER_SECOND;
|
unix_st.st_mtimespec.tv_sec = r_stat.st_mtimespec / NANOS_PER_SECOND;
|
||||||
|
|
||||||
unix_st.st_flags = r_stat.st_flags;
|
unix_st.st_flags = r_stat.st_flags;
|
||||||
#else
|
#else // !defined(__APPLE__)
|
||||||
unix_st.st_blksize = 4096;
|
unix_st.st_blksize = 4096;
|
||||||
|
|
||||||
unix_st.st_atim.tv_nsec =
|
unix_st.st_atim.tv_nsec =
|
||||||
@ -331,7 +331,8 @@ void remote_fuse_drive::populate_stat(const remote::stat &r_stat,
|
|||||||
static_cast<suseconds_t>(r_stat.st_mtimespec % NANOS_PER_SECOND);
|
static_cast<suseconds_t>(r_stat.st_mtimespec % NANOS_PER_SECOND);
|
||||||
unix_st.st_mtim.tv_sec =
|
unix_st.st_mtim.tv_sec =
|
||||||
static_cast<suseconds_t>(r_stat.st_mtimespec / NANOS_PER_SECOND);
|
static_cast<suseconds_t>(r_stat.st_mtimespec / NANOS_PER_SECOND);
|
||||||
#endif
|
#endif // defined(__APPLE__)
|
||||||
|
|
||||||
if (not directory) {
|
if (not directory) {
|
||||||
const auto block_size_stat = static_cast<std::uint64_t>(512U);
|
const auto block_size_stat = static_cast<std::uint64_t>(512U);
|
||||||
const auto block_size = static_cast<std::uint64_t>(4096U);
|
const auto block_size = static_cast<std::uint64_t>(4096U);
|
||||||
|
@ -92,10 +92,14 @@ void remote_server::populate_stat(const char *path, bool directory,
|
|||||||
directory ? 2 + drive_.get_directory_item_count(
|
directory ? 2 + drive_.get_directory_item_count(
|
||||||
utils::path::create_api_path(path))
|
utils::path::create_api_path(path))
|
||||||
: 1);
|
: 1);
|
||||||
r_stat.st_atimespec = utils::time::time64_to_unix_time(unix_st.st_atime);
|
r_stat.st_atimespec = utils::time::windows_time_to_unix_time(
|
||||||
r_stat.st_birthtimespec = utils::time::time64_to_unix_time(unix_st.st_ctime);
|
static_cast<std::uint64_t>(unix_st.st_atime));
|
||||||
r_stat.st_ctimespec = utils::time::time64_to_unix_time(unix_st.st_ctime);
|
r_stat.st_birthtimespec = utils::time::windows_time_to_unix_time(
|
||||||
r_stat.st_mtimespec = utils::time::time64_to_unix_time(unix_st.st_mtime);
|
static_cast<std::uint64_t>(unix_st.st_ctime));
|
||||||
|
r_stat.st_ctimespec = utils::time::windows_time_to_unix_time(
|
||||||
|
static_cast<std::uint64_t>(unix_st.st_ctime));
|
||||||
|
r_stat.st_mtimespec = utils::time::windows_time_to_unix_time(
|
||||||
|
static_cast<std::uint64_t>(unix_st.st_mtime));
|
||||||
r_stat.st_size = static_cast<remote::file_size>(unix_st.st_size);
|
r_stat.st_size = static_cast<remote::file_size>(unix_st.st_size);
|
||||||
r_stat.st_mode = unix_st.st_mode;
|
r_stat.st_mode = unix_st.st_mode;
|
||||||
}
|
}
|
||||||
|
@ -99,26 +99,15 @@ auto encrypt_provider::create_api_file(
|
|||||||
file.modified_date =
|
file.modified_date =
|
||||||
buf.st_mtimespec.tv_nsec + (buf.st_mtimespec.tv_sec * NANOS_PER_SECOND);
|
buf.st_mtimespec.tv_nsec + (buf.st_mtimespec.tv_sec * NANOS_PER_SECOND);
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
auto ft = utils::time::unix_time_to_filetime(
|
file.accessed_date = utils::time::windows_time_to_unix_time(
|
||||||
utils::time::time64_to_unix_time(buf.st_atime));
|
static_cast<std::uint64_t>(buf.st_atime));
|
||||||
file.accessed_date =
|
file.changed_date = utils::time::windows_time_to_unix_time(
|
||||||
(static_cast<std::uint64_t>(ft.dwHighDateTime) << 32U) | ft.dwLowDateTime;
|
static_cast<std::uint64_t>(buf.st_mtime));
|
||||||
|
file.creation_date = utils::time::windows_time_to_unix_time(
|
||||||
ft = utils::time::unix_time_to_filetime(
|
static_cast<std::uint64_t>(buf.st_ctime));
|
||||||
utils::time::time64_to_unix_time(buf.st_mtime));
|
file.modified_date = utils::time::windows_time_to_unix_time(
|
||||||
file.changed_date =
|
static_cast<std::uint64_t>(buf.st_mtime));
|
||||||
(static_cast<std::uint64_t>(ft.dwHighDateTime) << 32U) | ft.dwLowDateTime;
|
#else // !defined(_WIN32)
|
||||||
|
|
||||||
ft = utils::time::unix_time_to_filetime(
|
|
||||||
utils::time::time64_to_unix_time(buf.st_ctime));
|
|
||||||
file.creation_date =
|
|
||||||
(static_cast<std::uint64_t>(ft.dwHighDateTime) << 32U) | ft.dwLowDateTime;
|
|
||||||
|
|
||||||
ft = utils::time::unix_time_to_filetime(
|
|
||||||
utils::time::time64_to_unix_time(buf.st_mtime));
|
|
||||||
file.modified_date =
|
|
||||||
(static_cast<std::uint64_t>(ft.dwHighDateTime) << 32U) | ft.dwLowDateTime;
|
|
||||||
#else
|
|
||||||
file.changed_date = static_cast<std::uint64_t>(
|
file.changed_date = static_cast<std::uint64_t>(
|
||||||
buf.st_mtim.tv_nsec + (buf.st_mtim.tv_sec * NANOS_PER_SECOND));
|
buf.st_mtim.tv_nsec + (buf.st_mtim.tv_sec * NANOS_PER_SECOND));
|
||||||
file.accessed_date = static_cast<std::uint64_t>(
|
file.accessed_date = static_cast<std::uint64_t>(
|
||||||
@ -127,7 +116,7 @@ auto encrypt_provider::create_api_file(
|
|||||||
buf.st_ctim.tv_nsec + (buf.st_ctim.tv_sec * NANOS_PER_SECOND));
|
buf.st_ctim.tv_nsec + (buf.st_ctim.tv_sec * NANOS_PER_SECOND));
|
||||||
file.modified_date = static_cast<std::uint64_t>(
|
file.modified_date = static_cast<std::uint64_t>(
|
||||||
buf.st_mtim.tv_nsec + (buf.st_mtim.tv_sec * NANOS_PER_SECOND));
|
buf.st_mtim.tv_nsec + (buf.st_mtim.tv_sec * NANOS_PER_SECOND));
|
||||||
#endif
|
#endif // defined(__APPLE__)
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,8 @@ auto get_accessed_time(const std::string &path,
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
struct _stat64 st {};
|
struct _stat64 st {};
|
||||||
if (_stat64(path.c_str(), &st) != -1) {
|
if (_stat64(path.c_str(), &st) != -1) {
|
||||||
accessed = static_cast<uint64_t>(st.st_atime);
|
accessed = time::windows_time_to_unix_time(
|
||||||
|
static_cast<std::uint64_t>(st.st_atime));
|
||||||
#else
|
#else
|
||||||
struct stat st {};
|
struct stat st {};
|
||||||
if (stat(path.c_str(), &st) != -1) {
|
if (stat(path.c_str(), &st) != -1) {
|
||||||
@ -270,7 +271,8 @@ auto get_modified_time(const std::string &path,
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
struct _stat64 st {};
|
struct _stat64 st {};
|
||||||
if (_stat64(path.c_str(), &st) != -1) {
|
if (_stat64(path.c_str(), &st) != -1) {
|
||||||
modified = static_cast<uint64_t>(st.st_mtime);
|
modified = time::windows_time_to_unix_time(
|
||||||
|
static_cast<std::uint64_t>(st.st_mtime));
|
||||||
#else
|
#else
|
||||||
struct stat st {};
|
struct stat st {};
|
||||||
if (stat(path.c_str(), &st) != -1) {
|
if (stat(path.c_str(), &st) != -1) {
|
||||||
@ -293,18 +295,12 @@ auto is_modified_date_older_than(const std::string &path,
|
|||||||
auto ret = false;
|
auto ret = false;
|
||||||
std::uint64_t modified{};
|
std::uint64_t modified{};
|
||||||
if (get_modified_time(path, modified)) {
|
if (get_modified_time(path, modified)) {
|
||||||
const auto seconds =
|
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(hours);
|
||||||
std::chrono::duration_cast<std::chrono::seconds>(hours);
|
|
||||||
#if defined(_WIN32)
|
|
||||||
return (std::chrono::system_clock::from_time_t(
|
|
||||||
static_cast<time_t>(modified)) +
|
|
||||||
seconds) < std::chrono::system_clock::now();
|
|
||||||
#else
|
|
||||||
return (modified +
|
return (modified +
|
||||||
static_cast<std::uint64_t>(seconds.count() * NANOS_PER_SECOND)) <
|
static_cast<std::uint64_t>(seconds.count() * NANOS_PER_SECOND)) <
|
||||||
utils::time::get_time_now();
|
utils::time::get_time_now();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,15 +22,8 @@
|
|||||||
#include "utils/utils.hpp"
|
#include "utils/utils.hpp"
|
||||||
|
|
||||||
#include "app_config.hpp"
|
#include "app_config.hpp"
|
||||||
#include "events/event_system.hpp"
|
|
||||||
#include "events/events.hpp"
|
|
||||||
#include "providers/i_provider.hpp"
|
|
||||||
#include "types/startup_exception.hpp"
|
|
||||||
#include "utils/com_init_wrapper.hpp"
|
|
||||||
#include "utils/common.hpp"
|
#include "utils/common.hpp"
|
||||||
#include "utils/path.hpp"
|
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
#include "utils/time.hpp"
|
|
||||||
|
|
||||||
namespace repertory::utils {
|
namespace repertory::utils {
|
||||||
void calculate_allocation_size(bool directory, std::uint64_t file_size,
|
void calculate_allocation_size(bool directory, std::uint64_t file_size,
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "utils/config.hpp"
|
#include "utils/config.hpp"
|
||||||
|
|
||||||
namespace repertory::utils::time {
|
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_CONVERSION{116444736000000000ULL};
|
||||||
inline constexpr const auto WIN32_TIME_NANOS_PER_TICK{100ULL};
|
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)
|
#if defined(_WIN32)
|
||||||
auto strptime(const char *s, const char *f, struct tm *tm) -> const char *;
|
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;
|
[[nodiscard]] auto unix_time_to_filetime(std::uint64_t unix_time) -> FILETIME;
|
||||||
#endif // defined(_WIN32)
|
#endif // defined(_WIN32)
|
||||||
|
|
||||||
|
@ -75,7 +75,8 @@ auto i_fs_item::get_time(time_types type) const -> std::uint64_t {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case time_types::access:
|
case time_types::access:
|
||||||
#if defined(_WIN32)
|
#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)
|
#else // !defined(_WIN32)
|
||||||
return static_cast<std::uint64_t>(st.st_atim.tv_nsec +
|
return static_cast<std::uint64_t>(st.st_atim.tv_nsec +
|
||||||
st.st_atim.tv_sec *
|
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:
|
case time_types::creation:
|
||||||
#if defined(_WIN32)
|
#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)
|
#else // !defined(_WIN32)
|
||||||
return static_cast<std::uint64_t>(st.st_ctim.tv_nsec +
|
return static_cast<std::uint64_t>(st.st_ctim.tv_nsec +
|
||||||
st.st_ctim.tv_sec *
|
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:
|
case time_types::modified:
|
||||||
#if defined(_WIN32)
|
#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)
|
#else // !defined(_WIN32)
|
||||||
return static_cast<std::uint64_t>(st.st_mtim.tv_nsec +
|
return static_cast<std::uint64_t>(st.st_mtim.tv_nsec +
|
||||||
st.st_mtim.tv_sec *
|
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:
|
case time_types::write:
|
||||||
#if defined(_WIN32)
|
#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)
|
#else // !defined(_WIN32)
|
||||||
return static_cast<std::uint64_t>(st.st_mtim.tv_nsec +
|
return static_cast<std::uint64_t>(st.st_mtim.tv_nsec +
|
||||||
st.st_mtim.tv_sec *
|
st.st_mtim.tv_sec *
|
||||||
|
@ -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());
|
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/
|
// https://www.frenk.com/2009/12/convert-filetime-to-unix-timestamp/
|
||||||
auto unix_time_to_filetime(std::uint64_t unix_time) -> FILETIME {
|
auto unix_time_to_filetime(std::uint64_t unix_time) -> FILETIME {
|
||||||
auto win_time =
|
auto win_time =
|
||||||
|
Reference in New Issue
Block a user