updated build system
This commit is contained in:
@ -46,6 +46,10 @@ public:
|
||||
auto operator=(const s3_provider &) -> s3_provider & = delete;
|
||||
auto operator=(s3_provider &&) -> s3_provider & = delete;
|
||||
|
||||
public:
|
||||
[[nodiscard]] static auto
|
||||
convert_api_date(std::string_view date) -> std::uint64_t;
|
||||
|
||||
private:
|
||||
[[nodiscard]] auto
|
||||
add_if_not_found(api_file &file,
|
||||
|
@ -43,15 +43,9 @@ inline const std::array<std::string, 4U> attribute_namespaces = {
|
||||
|
||||
[[nodiscard]] auto unix_error_to_windows(int err) -> std::uint32_t;
|
||||
|
||||
[[nodiscard]] auto
|
||||
unix_time_to_windows_time(const remote::file_time &file_time) -> UINT64;
|
||||
|
||||
void windows_create_to_unix(const UINT32 &create_options,
|
||||
const UINT32 &granted_access, std::uint32_t &flags,
|
||||
remote::file_mode &mode);
|
||||
|
||||
[[nodiscard]] auto
|
||||
windows_time_to_unix_time(std::uint64_t win_time) -> remote::file_time;
|
||||
} // namespace repertory::utils
|
||||
|
||||
#endif // !_WIN32
|
||||
|
@ -125,18 +125,18 @@ void remote_server::populate_file_info(const std::string &api_path,
|
||||
file_info.AllocationSize =
|
||||
utils::divide_with_ceiling(file_size, WINFSP_ALLOCATION_UNIT) *
|
||||
WINFSP_ALLOCATION_UNIT;
|
||||
file_info.ChangeTime = utils::unix_time_to_windows_time(
|
||||
file_info.ChangeTime = utils::time::unix_time_to_windows_time(
|
||||
utils::string::to_uint64(empty_as_zero(meta[META_MODIFIED])));
|
||||
file_info.CreationTime = utils::unix_time_to_windows_time(
|
||||
file_info.CreationTime = utils::time::unix_time_to_windows_time(
|
||||
utils::string::to_uint64(empty_as_zero(meta[META_CREATION])));
|
||||
file_info.EaSize = 0;
|
||||
file_info.FileAttributes = attributes;
|
||||
file_info.FileSize = file_size;
|
||||
file_info.HardLinks = 0;
|
||||
file_info.IndexNumber = 0;
|
||||
file_info.LastAccessTime = utils::unix_time_to_windows_time(
|
||||
file_info.LastAccessTime = utils::time::unix_time_to_windows_time(
|
||||
utils::string::to_uint64(empty_as_zero(meta[META_ACCESSED])));
|
||||
file_info.LastWriteTime = utils::unix_time_to_windows_time(
|
||||
file_info.LastWriteTime = utils::time::unix_time_to_windows_time(
|
||||
utils::string::to_uint64(empty_as_zero(meta[META_WRITTEN])));
|
||||
if (meta[META_WRITTEN].empty() || (meta[META_WRITTEN] == "0") ||
|
||||
(meta[META_WRITTEN] == "116444736000000000")) {
|
||||
@ -1543,25 +1543,28 @@ auto remote_server::winfsp_set_basic_info(
|
||||
if ((creation_time != 0U) && (creation_time != max_time)) {
|
||||
drive_.set_item_meta(
|
||||
api_path, META_CREATION,
|
||||
std::to_string(utils::windows_time_to_unix_time(creation_time)));
|
||||
std::to_string(
|
||||
utils::time::windows_time_to_unix_time(creation_time)));
|
||||
}
|
||||
|
||||
if ((last_access_time != 0U) && (last_access_time != max_time)) {
|
||||
drive_.set_item_meta(
|
||||
api_path, META_ACCESSED,
|
||||
std::to_string(utils::windows_time_to_unix_time(last_access_time)));
|
||||
std::to_string(
|
||||
utils::time::windows_time_to_unix_time(last_access_time)));
|
||||
}
|
||||
|
||||
if ((last_write_time != 0U) && (last_write_time != max_time)) {
|
||||
drive_.set_item_meta(
|
||||
api_path, META_WRITTEN,
|
||||
std::to_string(utils::windows_time_to_unix_time(last_write_time)));
|
||||
std::to_string(
|
||||
utils::time::windows_time_to_unix_time(last_write_time)));
|
||||
}
|
||||
|
||||
if ((change_time != 0U) && (change_time != max_time)) {
|
||||
drive_.set_item_meta(
|
||||
api_path, META_MODIFIED,
|
||||
std::to_string(utils::windows_time_to_unix_time(change_time)));
|
||||
std::to_string(utils::time::windows_time_to_unix_time(change_time)));
|
||||
}
|
||||
|
||||
ret = populate_file_info(api_path, *file_info);
|
||||
@ -1746,12 +1749,15 @@ auto remote_server::json_release_directory_snapshot(
|
||||
|
||||
auto remote_server::update_to_windows_format(json &item) -> json & {
|
||||
const auto api_path = item["path"].get<std::string>();
|
||||
item["meta"][META_MODIFIED] = std::to_string(utils::unix_time_to_windows_time(
|
||||
utils::string::to_uint64(empty_as_zero(item["meta"][META_MODIFIED]))));
|
||||
item["meta"][META_CREATION] = std::to_string(utils::unix_time_to_windows_time(
|
||||
utils::string::to_uint64(empty_as_zero(item["meta"][META_CREATION]))));
|
||||
item["meta"][META_ACCESSED] = std::to_string(utils::unix_time_to_windows_time(
|
||||
utils::string::to_uint64(empty_as_zero(item["meta"][META_ACCESSED]))));
|
||||
item["meta"][META_MODIFIED] = std::to_string(
|
||||
utils::time::unix_time_to_windows_time(utils::string::to_uint64(
|
||||
empty_as_zero(item["meta"][META_MODIFIED]))));
|
||||
item["meta"][META_CREATION] = std::to_string(
|
||||
utils::time::unix_time_to_windows_time(utils::string::to_uint64(
|
||||
empty_as_zero(item["meta"][META_CREATION]))));
|
||||
item["meta"][META_ACCESSED] = std::to_string(
|
||||
utils::time::unix_time_to_windows_time(utils::string::to_uint64(
|
||||
empty_as_zero(item["meta"][META_ACCESSED]))));
|
||||
if (item["meta"][META_ATTRIBUTES].empty()) {
|
||||
item["meta"][META_ATTRIBUTES] =
|
||||
item["directory"].get<bool>() ? std::to_string(FILE_ATTRIBUTE_DIRECTORY)
|
||||
@ -1766,11 +1772,11 @@ auto remote_server::update_to_windows_format(json &item) -> json & {
|
||||
drive_.set_item_meta(api_path, META_WRITTEN,
|
||||
item["meta"][META_MODIFIED].get<std::string>());
|
||||
item["meta"][META_WRITTEN] = std::to_string(
|
||||
utils::unix_time_to_windows_time(utils::string::to_uint64(
|
||||
utils::time::unix_time_to_windows_time(utils::string::to_uint64(
|
||||
empty_as_zero(item["meta"][META_MODIFIED]))));
|
||||
} else {
|
||||
item["meta"][META_WRITTEN] = std::to_string(
|
||||
utils::unix_time_to_windows_time(utils::string::to_uint64(
|
||||
utils::time::unix_time_to_windows_time(utils::string::to_uint64(
|
||||
empty_as_zero(item["meta"][META_WRITTEN]))));
|
||||
}
|
||||
return item;
|
||||
|
@ -60,6 +60,24 @@ auto s3_provider::add_if_not_found(
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
auto s3_provider::convert_api_date(std::string_view date) -> std::uint64_t {
|
||||
// 2009-10-12T17:50:30.000Z
|
||||
auto date_parts = utils::string::split(date, '.', true);
|
||||
auto date_time = date_parts.at(0U);
|
||||
auto nanos = utils::string::to_uint64(
|
||||
utils::string::split(date_parts.at(1U), 'Z', true).at(0U));
|
||||
|
||||
struct tm tm1 {};
|
||||
#if defined(_WIN32)
|
||||
utils::time::strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
||||
#else
|
||||
strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
||||
#endif
|
||||
|
||||
return nanos + (static_cast<std::uint64_t>(mktime(&tm1)) *
|
||||
utils::time::NANOS_PER_SECOND);
|
||||
}
|
||||
|
||||
auto s3_provider::create_directory_impl(const std::string &api_path,
|
||||
api_meta_map &meta) -> api_error {
|
||||
static constexpr const std::string_view function_name{
|
||||
|
@ -201,10 +201,6 @@ auto unix_error_to_windows(int err) -> std::uint32_t {
|
||||
}
|
||||
}
|
||||
|
||||
auto unix_time_to_windows_time(const remote::file_time &file_time) -> UINT64 {
|
||||
return (file_time / 100ULL) + 116444736000000000ULL;
|
||||
}
|
||||
|
||||
void windows_create_to_unix(const UINT32 &create_options,
|
||||
const UINT32 &granted_access, std::uint32_t &flags,
|
||||
remote::file_mode &mode) {
|
||||
@ -221,10 +217,6 @@ void windows_create_to_unix(const UINT32 &create_options,
|
||||
mode |= (S_IXUSR);
|
||||
}
|
||||
}
|
||||
|
||||
auto windows_time_to_unix_time(std::uint64_t win_time) -> remote::file_time {
|
||||
return (win_time - 116444736000000000ULL) * 100ULL;
|
||||
}
|
||||
} // namespace repertory::utils
|
||||
|
||||
#endif // !_WIN32
|
||||
|
Reference in New Issue
Block a user