updated build system
This commit is contained in:
@ -63,8 +63,6 @@ inline constexpr const std::string_view REPERTORY_MIN_REMOTE_VERSION = "2.0.0";
|
|||||||
|
|
||||||
#define REPERTORY_INVALID_HANDLE INVALID_HANDLE_VALUE
|
#define REPERTORY_INVALID_HANDLE INVALID_HANDLE_VALUE
|
||||||
|
|
||||||
inline constexpr const auto NANOS_PER_SECOND = 1000000000L;
|
|
||||||
|
|
||||||
#define WINFSP_ALLOCATION_UNIT UINT64(4096U)
|
#define WINFSP_ALLOCATION_UNIT UINT64(4096U)
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
@ -22,14 +22,14 @@
|
|||||||
#ifndef INCLUDE_TYPES_REMOTE_HPP_
|
#ifndef INCLUDE_TYPES_REMOTE_HPP_
|
||||||
#define INCLUDE_TYPES_REMOTE_HPP_
|
#define INCLUDE_TYPES_REMOTE_HPP_
|
||||||
|
|
||||||
#define PACKET_SERVICE_FUSE 1U
|
inline constexpr const auto PACKET_SERVICE_FUSE{1U};
|
||||||
#define PACKET_SERVICE_WINFSP 2U
|
inline constexpr const auto PACKET_SERVICE_WINFSP{2U};
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define PACKET_SERVICE_FLAGS PACKET_SERVICE_WINFSP
|
inline constexpr const auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_WINFSP};
|
||||||
#else
|
#else // !defined(_WIN32)
|
||||||
#define PACKET_SERVICE_FLAGS PACKET_SERVICE_FUSE
|
inline constexpr const auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_FUSE};
|
||||||
#endif
|
#endif // defined(_WIN32)
|
||||||
|
|
||||||
namespace repertory::remote {
|
namespace repertory::remote {
|
||||||
using block_count = std::uint64_t;
|
using block_count = std::uint64_t;
|
||||||
@ -65,16 +65,19 @@ enum class open_flags : std::uint32_t {
|
|||||||
dsync = 131072U,
|
dsync = 131072U,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline auto operator|(const open_flags &flag_1,
|
#if defined(__GNUG__)
|
||||||
const open_flags &flag_2) -> open_flags {
|
__attribute__((unused))
|
||||||
using t = std::underlying_type_t<open_flags>;
|
#endif // defined(__GNUG__)
|
||||||
return static_cast<open_flags>(static_cast<t>(flag_1) |
|
[[nodiscard]] inline auto
|
||||||
static_cast<t>(flag_2));
|
operator|(const open_flags &flag_1, const open_flags &flag_2) -> open_flags {
|
||||||
|
using flag_t = std::underlying_type_t<open_flags>;
|
||||||
|
return static_cast<open_flags>(static_cast<flag_t>(flag_1) |
|
||||||
|
static_cast<flag_t>(flag_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUG__)
|
#if defined(__GNUG__)
|
||||||
__attribute__((unused))
|
__attribute__((unused))
|
||||||
#endif
|
#endif // defined(__GNUG__)
|
||||||
inline auto
|
inline auto
|
||||||
operator|=(open_flags &flag_1, const open_flags &flag_2) -> open_flags & {
|
operator|=(open_flags &flag_1, const open_flags &flag_2) -> open_flags & {
|
||||||
flag_1 = flag_1 | flag_2;
|
flag_1 = flag_1 | flag_2;
|
||||||
@ -83,69 +86,69 @@ operator|=(open_flags &flag_1, const open_flags &flag_2) -> open_flags & {
|
|||||||
|
|
||||||
#if defined(__GNUG__)
|
#if defined(__GNUG__)
|
||||||
__attribute__((unused))
|
__attribute__((unused))
|
||||||
#endif
|
#endif // defined(__GNUG__)
|
||||||
inline auto
|
[[nodiscard]] inline auto
|
||||||
operator&(const open_flags &flag_1, const open_flags &flag_2) -> open_flags {
|
operator&(const open_flags &flag_1, const open_flags &flag_2) -> open_flags {
|
||||||
using t = std::underlying_type_t<open_flags>;
|
using flag_t = std::underlying_type_t<open_flags>;
|
||||||
return static_cast<open_flags>(static_cast<t>(flag_1) &
|
return static_cast<open_flags>(static_cast<flag_t>(flag_1) &
|
||||||
static_cast<t>(flag_2));
|
static_cast<flag_t>(flag_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
struct file_info {
|
struct file_info final {
|
||||||
UINT32 FileAttributes;
|
UINT32 FileAttributes{};
|
||||||
UINT32 ReparseTag;
|
UINT32 ReparseTag{};
|
||||||
UINT64 AllocationSize;
|
UINT64 AllocationSize{};
|
||||||
UINT64 FileSize;
|
UINT64 FileSize{};
|
||||||
UINT64 CreationTime;
|
UINT64 CreationTime{};
|
||||||
UINT64 LastAccessTime;
|
UINT64 LastAccessTime{};
|
||||||
UINT64 LastWriteTime;
|
UINT64 LastWriteTime{};
|
||||||
UINT64 ChangeTime;
|
UINT64 ChangeTime{};
|
||||||
UINT64 IndexNumber;
|
UINT64 IndexNumber{};
|
||||||
UINT32 HardLinks;
|
UINT32 HardLinks{};
|
||||||
UINT32 EaSize;
|
UINT32 EaSize{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct setattr_x {
|
struct setattr_x final {
|
||||||
std::int32_t valid;
|
std::int32_t valid{};
|
||||||
file_mode mode;
|
file_mode mode{};
|
||||||
user_id uid;
|
user_id uid{};
|
||||||
group_id gid;
|
group_id gid{};
|
||||||
file_size size;
|
file_size size{};
|
||||||
file_time acctime;
|
file_time acctime{};
|
||||||
file_time modtime;
|
file_time modtime{};
|
||||||
file_time crtime;
|
file_time crtime{};
|
||||||
file_time chgtime;
|
file_time chgtime{};
|
||||||
file_time bkuptime;
|
file_time bkuptime{};
|
||||||
std::uint32_t flags;
|
std::uint32_t flags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct stat {
|
struct stat final {
|
||||||
file_mode st_mode;
|
file_mode st_mode{};
|
||||||
file_nlink st_nlink;
|
file_nlink st_nlink{};
|
||||||
user_id st_uid;
|
user_id st_uid{};
|
||||||
group_id st_gid;
|
group_id st_gid{};
|
||||||
file_time st_atimespec;
|
file_time st_atimespec{};
|
||||||
file_time st_mtimespec;
|
file_time st_mtimespec{};
|
||||||
file_time st_ctimespec;
|
file_time st_ctimespec{};
|
||||||
file_time st_birthtimespec;
|
file_time st_birthtimespec{};
|
||||||
file_size st_size;
|
file_size st_size{};
|
||||||
block_count st_blocks;
|
block_count st_blocks{};
|
||||||
block_size st_blksize;
|
block_size st_blksize{};
|
||||||
std::uint32_t st_flags;
|
std::uint32_t st_flags{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct statfs {
|
struct statfs {
|
||||||
std::uint64_t f_bavail;
|
std::uint64_t f_bavail{};
|
||||||
std::uint64_t f_bfree;
|
std::uint64_t f_bfree{};
|
||||||
std::uint64_t f_blocks;
|
std::uint64_t f_blocks{};
|
||||||
std::uint64_t f_favail;
|
std::uint64_t f_favail{};
|
||||||
std::uint64_t f_ffree;
|
std::uint64_t f_ffree{};
|
||||||
std::uint64_t f_files;
|
std::uint64_t f_files{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct statfs_x : public statfs {
|
struct statfs_x : public statfs {
|
||||||
char f_mntfromname[1024];
|
std::array<char, 1024U> f_mntfromname{};
|
||||||
};
|
};
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
@ -154,7 +157,7 @@ struct statfs_x : public statfs {
|
|||||||
|
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto
|
||||||
create_os_open_flags(const open_flags &flags) -> std::uint32_t;
|
create_os_open_flags(const open_flags &flags) -> std::uint32_t;
|
||||||
#endif
|
#endif // !defined(_WIN32)
|
||||||
} // namespace repertory::remote
|
} // namespace repertory::remote
|
||||||
|
|
||||||
#endif // INCLUDE_TYPES_REMOTE_HPP_
|
#endif // INCLUDE_TYPES_REMOTE_HPP_
|
||||||
|
@ -79,8 +79,8 @@ struct head_object_result {
|
|||||||
#else
|
#else
|
||||||
strptime(date.c_str(), "%a, %d %b %Y %H:%M:%S %Z", &tm1);
|
strptime(date.c_str(), "%a, %d %b %Y %H:%M:%S %Z", &tm1);
|
||||||
#endif
|
#endif
|
||||||
last_modified =
|
last_modified = static_cast<std::uint64_t>(mktime(&tm1)) *
|
||||||
static_cast<std::uint64_t>(mktime(&tm1)) * NANOS_PER_SECOND;
|
utils::time::NANOS_PER_SECOND;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,6 @@ void change_to_process_directory();
|
|||||||
[[nodiscard]] auto copy_file(std::string from_path,
|
[[nodiscard]] auto copy_file(std::string from_path,
|
||||||
std::string to_path) -> bool;
|
std::string to_path) -> bool;
|
||||||
|
|
||||||
[[nodiscard]] auto get_accessed_time(const std::string &path,
|
|
||||||
std::uint64_t &accessed) -> bool;
|
|
||||||
|
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto
|
||||||
get_directory_files(std::string path, bool oldest_first,
|
get_directory_files(std::string path, bool oldest_first,
|
||||||
bool recursive = false) -> std::deque<std::string>;
|
bool recursive = false) -> std::deque<std::string>;
|
||||||
@ -47,11 +44,8 @@ get_free_drive_space(const std::string &path) -> std::uint64_t;
|
|||||||
[[nodiscard]] auto
|
[[nodiscard]] auto
|
||||||
get_total_drive_space(const std::string &path) -> std::uint64_t;
|
get_total_drive_space(const std::string &path) -> std::uint64_t;
|
||||||
|
|
||||||
[[nodiscard]] auto get_modified_time(const std::string &path,
|
|
||||||
std::uint64_t &modified) -> bool;
|
|
||||||
|
|
||||||
[[nodiscard]] auto
|
[[nodiscard]] auto
|
||||||
is_modified_date_older_than(const std::string &path,
|
is_modified_date_older_than(std::string_view path,
|
||||||
const std::chrono::hours &hours) -> bool;
|
const std::chrono::hours &hours) -> bool;
|
||||||
|
|
||||||
[[nodiscard]] auto move_file(std::string from, std::string to) -> bool;
|
[[nodiscard]] auto move_file(std::string from, std::string to) -> bool;
|
||||||
|
@ -194,7 +194,7 @@ auto packet::decode(remote::statfs &val) -> packet::error_type {
|
|||||||
auto packet::decode(remote::statfs_x &val) -> packet::error_type {
|
auto packet::decode(remote::statfs_x &val) -> packet::error_type {
|
||||||
auto ret = decode(*dynamic_cast<remote::statfs *>(&val));
|
auto ret = decode(*dynamic_cast<remote::statfs *>(&val));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = decode(&val.f_mntfromname[0U], sizeof(val.f_mntfromname));
|
ret = decode(val.f_mntfromname.data(), val.f_mntfromname.size());
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -372,9 +372,9 @@ void packet::encode(remote::statfs val, bool should_reserve) {
|
|||||||
|
|
||||||
void packet::encode(remote::statfs_x val) {
|
void packet::encode(remote::statfs_x val) {
|
||||||
buffer_.reserve(buffer_.size() + sizeof(remote::statfs) +
|
buffer_.reserve(buffer_.size() + sizeof(remote::statfs) +
|
||||||
sizeof(val.f_mntfromname));
|
val.f_mntfromname.size());
|
||||||
encode(*dynamic_cast<remote::statfs *>(&val), false);
|
encode(*dynamic_cast<remote::statfs *>(&val), false);
|
||||||
encode(&val.f_mntfromname[0], sizeof(val.f_mntfromname), false);
|
encode(val.f_mntfromname.data(), val.f_mntfromname.size(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void packet::encode(remote::file_info val) {
|
void packet::encode(remote::file_info val) {
|
||||||
@ -501,8 +501,8 @@ void packet::encode_top(remote::statfs val, bool should_reserve) {
|
|||||||
|
|
||||||
void packet::encode_top(remote::statfs_x val) {
|
void packet::encode_top(remote::statfs_x val) {
|
||||||
buffer_.reserve(buffer_.size() + sizeof(remote::statfs) +
|
buffer_.reserve(buffer_.size() + sizeof(remote::statfs) +
|
||||||
sizeof(val.f_mntfromname));
|
val.f_mntfromname.size());
|
||||||
encode_top(&val.f_mntfromname[0], sizeof(val.f_mntfromname), false);
|
encode_top(val.f_mntfromname.data(), val.f_mntfromname.size(), false);
|
||||||
encode_top(*dynamic_cast<remote::statfs *>(&val), false);
|
encode_top(*dynamic_cast<remote::statfs *>(&val), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,30 +46,19 @@ auto eviction::check_minimum_requirements(const std::string &file_path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto file_size{opt_size.value()};
|
auto file_size{opt_size.value()};
|
||||||
auto ret{false};
|
if (file_size == 0U) {
|
||||||
if (file_size != 0U) {
|
return false;
|
||||||
std::uint64_t reference_time{};
|
|
||||||
ret = config_.get_eviction_uses_accessed_time()
|
|
||||||
? utils::file::get_accessed_time(file_path, reference_time)
|
|
||||||
: utils::file::get_modified_time(file_path, reference_time);
|
|
||||||
if (ret) {
|
|
||||||
#if defined(_WIN32)
|
|
||||||
const auto now = std::chrono::system_clock::now();
|
|
||||||
const auto delay =
|
|
||||||
std::chrono::minutes(config_.get_eviction_delay_mins());
|
|
||||||
ret = ((std::chrono::system_clock::from_time_t(
|
|
||||||
static_cast<time_t>(reference_time)) +
|
|
||||||
delay) <= now);
|
|
||||||
#else
|
|
||||||
const auto now = utils::time::get_time_now();
|
|
||||||
const auto delay =
|
|
||||||
(config_.get_eviction_delay_mins() * 60L) * NANOS_PER_SECOND;
|
|
||||||
ret = ((reference_time + static_cast<std::uint64_t>(delay)) <= now);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
auto reference_time = utils::file::file{file_path}.get_time(
|
||||||
|
config_.get_eviction_uses_accessed_time()
|
||||||
|
? utils::file::file::time_types::access
|
||||||
|
: utils::file::file::time_types::modified);
|
||||||
|
|
||||||
|
auto delay = (config_.get_eviction_delay_mins() * 60UL) *
|
||||||
|
utils::time::NANOS_PER_SECOND;
|
||||||
|
return ((reference_time + static_cast<std::uint64_t>(delay)) <=
|
||||||
|
utils::time::get_time_now());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto eviction::get_filtered_cached_files() -> std::deque<std::string> {
|
auto eviction::get_filtered_cached_files() -> std::deque<std::string> {
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "utils/error_utils.hpp"
|
#include "utils/error_utils.hpp"
|
||||||
#include "utils/file_utils.hpp"
|
#include "utils/file_utils.hpp"
|
||||||
#include "utils/path.hpp"
|
#include "utils/path.hpp"
|
||||||
|
#include "utils/time.hpp"
|
||||||
#include "utils/utils.hpp"
|
#include "utils/utils.hpp"
|
||||||
|
|
||||||
namespace repertory::remote_fuse {
|
namespace repertory::remote_fuse {
|
||||||
@ -142,16 +143,17 @@ api_error remote_fuse_drive::fsetattr_x_impl(std::string api_path,
|
|||||||
attributes.uid = attr->uid;
|
attributes.uid = attr->uid;
|
||||||
attributes.gid = attr->gid;
|
attributes.gid = attr->gid;
|
||||||
attributes.size = attr->size;
|
attributes.size = attr->size;
|
||||||
attributes.acctime =
|
attributes.acctime = ((attr->acctime.tv_sec * utils::time::NANOS_PER_SECOND) +
|
||||||
((attr->acctime.tv_sec * NANOS_PER_SECOND) + attr->acctime.tv_nsec);
|
attr->acctime.tv_nsec);
|
||||||
attributes.modtime =
|
attributes.modtime = ((attr->modtime.tv_sec * utils::time::NANOS_PER_SECOND) +
|
||||||
((attr->modtime.tv_sec * NANOS_PER_SECOND) + attr->modtime.tv_nsec);
|
attr->modtime.tv_nsec);
|
||||||
attributes.crtime =
|
attributes.crtime = ((attr->crtime.tv_sec * utils::time::NANOS_PER_SECOND) +
|
||||||
((attr->crtime.tv_sec * NANOS_PER_SECOND) + attr->crtime.tv_nsec);
|
attr->crtime.tv_nsec);
|
||||||
attributes.chgtime =
|
attributes.chgtime = ((attr->chgtime.tv_sec * utils::time::NANOS_PER_SECOND) +
|
||||||
((attr->chgtime.tv_sec * NANOS_PER_SECOND) + attr->chgtime.tv_nsec);
|
attr->chgtime.tv_nsec);
|
||||||
attributes.bkuptime =
|
attributes.bkuptime =
|
||||||
((attr->bkuptime.tv_sec * NANOS_PER_SECOND) + attr->bkuptime.tv_nsec);
|
((attr->bkuptime.tv_sec * utils::time::NANOS_PER_SECOND) +
|
||||||
|
attr->bkuptime.tv_nsec);
|
||||||
attributes.flags = attr->flags;
|
attributes.flags = attr->flags;
|
||||||
return utils::to_api_error(remote_instance_->fuse_fsetattr_x(
|
return utils::to_api_error(remote_instance_->fuse_fsetattr_x(
|
||||||
api_path.c_str(), attributes, f_info->fh));
|
api_path.c_str(), attributes, f_info->fh));
|
||||||
@ -208,10 +210,11 @@ api_error remote_fuse_drive::getxtimes_impl(std::string api_path,
|
|||||||
api_path.c_str(), repertory_bkuptime, repertory_crtime);
|
api_path.c_str(), repertory_bkuptime, repertory_crtime);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
bkuptime->tv_nsec =
|
bkuptime->tv_nsec =
|
||||||
static_cast<long>(repertory_bkuptime % NANOS_PER_SECOND);
|
static_cast<long>(repertory_bkuptime % utils::time::NANOS_PER_SECOND);
|
||||||
bkuptime->tv_sec = repertory_bkuptime / NANOS_PER_SECOND;
|
bkuptime->tv_sec = repertory_bkuptime / utils::time::NANOS_PER_SECOND;
|
||||||
crtime->tv_nsec = static_cast<long>(repertory_crtime % NANOS_PER_SECOND);
|
crtime->tv_nsec =
|
||||||
crtime->tv_sec = repertory_crtime / NANOS_PER_SECOND;
|
static_cast<long>(repertory_crtime % utils::time::NANOS_PER_SECOND);
|
||||||
|
crtime->tv_sec = repertory_crtime / utils::time::NANOS_PER_SECOND;
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils::to_api_error(res);
|
return utils::to_api_error(res);
|
||||||
@ -301,36 +304,44 @@ void remote_fuse_drive::populate_stat(const remote::stat &r_stat,
|
|||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
unix_st.st_blksize = 0;
|
unix_st.st_blksize = 0;
|
||||||
|
|
||||||
unix_st.st_atimespec.tv_nsec = r_stat.st_atimespec % NANOS_PER_SECOND;
|
unix_st.st_atimespec.tv_nsec =
|
||||||
unix_st.st_atimespec.tv_sec = r_stat.st_atimespec / NANOS_PER_SECOND;
|
r_stat.st_atimespec % utils::time::NANOS_PER_SECOND;
|
||||||
|
unix_st.st_atimespec.tv_sec =
|
||||||
|
r_stat.st_atimespec / utils::time::NANOS_PER_SECOND;
|
||||||
|
|
||||||
unix_st.st_birthtimespec.tv_nsec = r_stat.st_birthtimespec % NANOS_PER_SECOND;
|
unix_st.st_birthtimespec.tv_nsec =
|
||||||
unix_st.st_birthtimespec.tv_sec = r_stat.st_birthtimespec / NANOS_PER_SECOND;
|
r_stat.st_birthtimespec % utils::time::NANOS_PER_SECOND;
|
||||||
|
unix_st.st_birthtimespec.tv_sec =
|
||||||
|
r_stat.st_birthtimespec / utils::time::NANOS_PER_SECOND;
|
||||||
|
|
||||||
unix_st.st_ctimespec.tv_nsec = r_stat.st_ctimespec % NANOS_PER_SECOND;
|
unix_st.st_ctimespec.tv_nsec =
|
||||||
unix_st.st_ctimespec.tv_sec = r_stat.st_ctimespec / NANOS_PER_SECOND;
|
r_stat.st_ctimespec % utils::time::NANOS_PER_SECOND;
|
||||||
|
unix_st.st_ctimespec.tv_sec =
|
||||||
|
r_stat.st_ctimespec / utils::time::NANOS_PER_SECOND;
|
||||||
|
|
||||||
unix_st.st_mtimespec.tv_nsec = r_stat.st_mtimespec % NANOS_PER_SECOND;
|
unix_st.st_mtimespec.tv_nsec =
|
||||||
unix_st.st_mtimespec.tv_sec = r_stat.st_mtimespec / NANOS_PER_SECOND;
|
r_stat.st_mtimespec % utils::time::NANOS_PER_SECOND;
|
||||||
|
unix_st.st_mtimespec.tv_sec =
|
||||||
|
r_stat.st_mtimespec / utils::time::NANOS_PER_SECOND;
|
||||||
|
|
||||||
unix_st.st_flags = r_stat.st_flags;
|
unix_st.st_flags = r_stat.st_flags;
|
||||||
#else // !defined(__APPLE__)
|
#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 = static_cast<suseconds_t>(
|
||||||
static_cast<suseconds_t>(r_stat.st_atimespec % NANOS_PER_SECOND);
|
r_stat.st_atimespec % utils::time::NANOS_PER_SECOND);
|
||||||
unix_st.st_atim.tv_sec =
|
unix_st.st_atim.tv_sec = static_cast<suseconds_t>(
|
||||||
static_cast<suseconds_t>(r_stat.st_atimespec / NANOS_PER_SECOND);
|
r_stat.st_atimespec / utils::time::NANOS_PER_SECOND);
|
||||||
|
|
||||||
unix_st.st_ctim.tv_nsec =
|
unix_st.st_ctim.tv_nsec = static_cast<suseconds_t>(
|
||||||
static_cast<suseconds_t>(r_stat.st_ctimespec % NANOS_PER_SECOND);
|
r_stat.st_ctimespec % utils::time::NANOS_PER_SECOND);
|
||||||
unix_st.st_ctim.tv_sec =
|
unix_st.st_ctim.tv_sec = static_cast<suseconds_t>(
|
||||||
static_cast<suseconds_t>(r_stat.st_ctimespec / NANOS_PER_SECOND);
|
r_stat.st_ctimespec / utils::time::NANOS_PER_SECOND);
|
||||||
|
|
||||||
unix_st.st_mtim.tv_nsec =
|
unix_st.st_mtim.tv_nsec = static_cast<suseconds_t>(
|
||||||
static_cast<suseconds_t>(r_stat.st_mtimespec % NANOS_PER_SECOND);
|
r_stat.st_mtimespec % utils::time::NANOS_PER_SECOND);
|
||||||
unix_st.st_mtim.tv_sec =
|
unix_st.st_mtim.tv_sec = static_cast<suseconds_t>(
|
||||||
static_cast<suseconds_t>(r_stat.st_mtimespec / NANOS_PER_SECOND);
|
r_stat.st_mtimespec / utils::time::NANOS_PER_SECOND);
|
||||||
#endif // defined(__APPLE__)
|
#endif // defined(__APPLE__)
|
||||||
|
|
||||||
if (not directory) {
|
if (not directory) {
|
||||||
@ -441,16 +452,17 @@ api_error remote_fuse_drive::setattr_x_impl(std::string api_path,
|
|||||||
attributes.uid = attr->uid;
|
attributes.uid = attr->uid;
|
||||||
attributes.gid = attr->gid;
|
attributes.gid = attr->gid;
|
||||||
attributes.size = attr->size;
|
attributes.size = attr->size;
|
||||||
attributes.acctime =
|
attributes.acctime = ((attr->acctime.tv_sec * utils::time::NANOS_PER_SECOND) +
|
||||||
((attr->acctime.tv_sec * NANOS_PER_SECOND) + attr->acctime.tv_nsec);
|
attr->acctime.tv_nsec);
|
||||||
attributes.modtime =
|
attributes.modtime = ((attr->modtime.tv_sec * utils::time::NANOS_PER_SECOND) +
|
||||||
((attr->modtime.tv_sec * NANOS_PER_SECOND) + attr->modtime.tv_nsec);
|
attr->modtime.tv_nsec);
|
||||||
attributes.crtime =
|
attributes.crtime = ((attr->crtime.tv_sec * utils::time::NANOS_PER_SECOND) +
|
||||||
((attr->crtime.tv_sec * NANOS_PER_SECOND) + attr->crtime.tv_nsec);
|
attr->crtime.tv_nsec);
|
||||||
attributes.chgtime =
|
attributes.chgtime = ((attr->chgtime.tv_sec * utils::time::NANOS_PER_SECOND) +
|
||||||
((attr->chgtime.tv_sec * NANOS_PER_SECOND) + attr->chgtime.tv_nsec);
|
attr->chgtime.tv_nsec);
|
||||||
attributes.bkuptime =
|
attributes.bkuptime =
|
||||||
((attr->bkuptime.tv_sec * NANOS_PER_SECOND) + attr->bkuptime.tv_nsec);
|
((attr->bkuptime.tv_sec * utils::time::NANOS_PER_SECOND) +
|
||||||
|
attr->bkuptime.tv_nsec);
|
||||||
attributes.flags = attr->flags;
|
attributes.flags = attr->flags;
|
||||||
return utils::to_api_error(
|
return utils::to_api_error(
|
||||||
remote_instance_->fuse_setattr_x(api_path.c_str(), attributes));
|
remote_instance_->fuse_setattr_x(api_path.c_str(), attributes));
|
||||||
@ -459,7 +471,7 @@ api_error remote_fuse_drive::setattr_x_impl(std::string api_path,
|
|||||||
api_error remote_fuse_drive::setbkuptime_impl(std::string api_path,
|
api_error remote_fuse_drive::setbkuptime_impl(std::string api_path,
|
||||||
const struct timespec *bkuptime) {
|
const struct timespec *bkuptime) {
|
||||||
remote::file_time repertory_bkuptime =
|
remote::file_time repertory_bkuptime =
|
||||||
((bkuptime->tv_sec * NANOS_PER_SECOND) + bkuptime->tv_nsec);
|
((bkuptime->tv_sec * utils::time::NANOS_PER_SECOND) + bkuptime->tv_nsec);
|
||||||
return utils::to_api_error(
|
return utils::to_api_error(
|
||||||
remote_instance_->fuse_setbkuptime(api_path.c_str(), repertory_bkuptime));
|
remote_instance_->fuse_setbkuptime(api_path.c_str(), repertory_bkuptime));
|
||||||
}
|
}
|
||||||
@ -467,7 +479,7 @@ api_error remote_fuse_drive::setbkuptime_impl(std::string api_path,
|
|||||||
api_error remote_fuse_drive::setchgtime_impl(std::string api_path,
|
api_error remote_fuse_drive::setchgtime_impl(std::string api_path,
|
||||||
const struct timespec *chgtime) {
|
const struct timespec *chgtime) {
|
||||||
remote::file_time repertory_chgtime =
|
remote::file_time repertory_chgtime =
|
||||||
((chgtime->tv_sec * NANOS_PER_SECOND) + chgtime->tv_nsec);
|
((chgtime->tv_sec * utils::time::NANOS_PER_SECOND) + chgtime->tv_nsec);
|
||||||
return utils::to_api_error(
|
return utils::to_api_error(
|
||||||
remote_instance_->fuse_setchgtime(api_path.c_str(), repertory_chgtime));
|
remote_instance_->fuse_setchgtime(api_path.c_str(), repertory_chgtime));
|
||||||
}
|
}
|
||||||
@ -475,7 +487,7 @@ api_error remote_fuse_drive::setchgtime_impl(std::string api_path,
|
|||||||
api_error remote_fuse_drive::setcrtime_impl(std::string api_path,
|
api_error remote_fuse_drive::setcrtime_impl(std::string api_path,
|
||||||
const struct timespec *crtime) {
|
const struct timespec *crtime) {
|
||||||
remote::file_time repertory_crtime =
|
remote::file_time repertory_crtime =
|
||||||
((crtime->tv_sec * NANOS_PER_SECOND) + crtime->tv_nsec);
|
((crtime->tv_sec * utils::time::NANOS_PER_SECOND) + crtime->tv_nsec);
|
||||||
return utils::to_api_error(
|
return utils::to_api_error(
|
||||||
remote_instance_->fuse_setcrtime(api_path.c_str(), repertory_crtime));
|
remote_instance_->fuse_setcrtime(api_path.c_str(), repertory_crtime));
|
||||||
}
|
}
|
||||||
@ -498,7 +510,7 @@ api_error remote_fuse_drive::statfs_x_impl(std::string api_path,
|
|||||||
stbuf->f_files = r.f_files;
|
stbuf->f_files = r.f_files;
|
||||||
stbuf->f_owner = getuid();
|
stbuf->f_owner = getuid();
|
||||||
strncpy(&stbuf->f_mntonname[0U], get_mount_location().c_str(), MNAMELEN);
|
strncpy(&stbuf->f_mntonname[0U], get_mount_location().c_str(), MNAMELEN);
|
||||||
strncpy(&stbuf->f_mntfromname[0U], &r.f_mntfromname[0U], MNAMELEN);
|
strncpy(stbuf->f_mntfromname.data(), &r.f_mntonname[0U], MNAMELEN);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
@ -557,9 +569,9 @@ auto remote_fuse_drive::utimens_impl(std::string api_path,
|
|||||||
remote::file_time rtv[2U] = {0};
|
remote::file_time rtv[2U] = {0};
|
||||||
if (tv != nullptr) {
|
if (tv != nullptr) {
|
||||||
rtv[0U] = static_cast<remote::file_time>(
|
rtv[0U] = static_cast<remote::file_time>(
|
||||||
tv[0U].tv_nsec + (tv[0U].tv_sec * NANOS_PER_SECOND));
|
tv[0U].tv_nsec + (tv[0U].tv_sec * utils::time::NANOS_PER_SECOND));
|
||||||
rtv[1U] = static_cast<remote::file_time>(
|
rtv[1U] = static_cast<remote::file_time>(
|
||||||
tv[1U].tv_nsec + (tv[1U].tv_sec * NANOS_PER_SECOND));
|
tv[1U].tv_nsec + (tv[1U].tv_sec * utils::time::NANOS_PER_SECOND));
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils::to_api_error(remote_instance_->fuse_utimens(
|
return utils::to_api_error(remote_instance_->fuse_utimens(
|
||||||
|
@ -152,26 +152,33 @@ void remote_server::populate_stat(const struct stat64 &unix_st,
|
|||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
r_stat.st_flags = unix_st.st_flags;
|
r_stat.st_flags = unix_st.st_flags;
|
||||||
|
|
||||||
r_stat.st_atimespec = unix_st.st_atimespec.tv_nsec +
|
r_stat.st_atimespec =
|
||||||
(unix_st.st_atimespec.tv_sec * NANOS_PER_SECOND);
|
unix_st.st_atimespec.tv_nsec +
|
||||||
|
(unix_st.st_atimespec.tv_sec * utils::time::NANOS_PER_SECOND);
|
||||||
r_stat.st_birthtimespec =
|
r_stat.st_birthtimespec =
|
||||||
unix_st.st_birthtimespec.tv_nsec +
|
unix_st.st_birthtimespec.tv_nsec +
|
||||||
(unix_st.st_birthtimespec.tv_sec * NANOS_PER_SECOND);
|
(unix_st.st_birthtimespec.tv_sec * utils::time::NANOS_PER_SECOND);
|
||||||
r_stat.st_ctimespec = unix_st.st_ctimespec.tv_nsec +
|
r_stat.st_ctimespec =
|
||||||
(unix_st.st_ctimespec.tv_sec * NANOS_PER_SECOND);
|
unix_st.st_ctimespec.tv_nsec +
|
||||||
r_stat.st_mtimespec = unix_st.st_mtimespec.tv_nsec +
|
(unix_st.st_ctimespec.tv_sec * utils::time::NANOS_PER_SECOND);
|
||||||
(unix_st.st_mtimespec.tv_sec * NANOS_PER_SECOND);
|
r_stat.st_mtimespec =
|
||||||
|
unix_st.st_mtimespec.tv_nsec +
|
||||||
|
(unix_st.st_mtimespec.tv_sec * utils::time::NANOS_PER_SECOND);
|
||||||
#else // !defined(__APPLE__)
|
#else // !defined(__APPLE__)
|
||||||
r_stat.st_flags = 0;
|
r_stat.st_flags = 0;
|
||||||
|
|
||||||
r_stat.st_atimespec = static_cast<remote::file_time>(
|
r_stat.st_atimespec = static_cast<remote::file_time>(
|
||||||
unix_st.st_atim.tv_nsec + (unix_st.st_atim.tv_sec * NANOS_PER_SECOND));
|
unix_st.st_atim.tv_nsec +
|
||||||
|
(unix_st.st_atim.tv_sec * utils::time::NANOS_PER_SECOND));
|
||||||
r_stat.st_birthtimespec = static_cast<remote::file_time>(
|
r_stat.st_birthtimespec = static_cast<remote::file_time>(
|
||||||
unix_st.st_ctim.tv_nsec + (unix_st.st_ctim.tv_sec * NANOS_PER_SECOND));
|
unix_st.st_ctim.tv_nsec +
|
||||||
|
(unix_st.st_ctim.tv_sec * utils::time::NANOS_PER_SECOND));
|
||||||
r_stat.st_ctimespec = static_cast<remote::file_time>(
|
r_stat.st_ctimespec = static_cast<remote::file_time>(
|
||||||
unix_st.st_ctim.tv_nsec + (unix_st.st_ctim.tv_sec * NANOS_PER_SECOND));
|
unix_st.st_ctim.tv_nsec +
|
||||||
|
(unix_st.st_ctim.tv_sec * utils::time::NANOS_PER_SECOND));
|
||||||
r_stat.st_mtimespec = static_cast<remote::file_time>(
|
r_stat.st_mtimespec = static_cast<remote::file_time>(
|
||||||
unix_st.st_mtim.tv_nsec + (unix_st.st_mtim.tv_sec * NANOS_PER_SECOND));
|
unix_st.st_mtim.tv_nsec +
|
||||||
|
(unix_st.st_mtim.tv_sec * utils::time::NANOS_PER_SECOND));
|
||||||
#endif // defined(__APPLE__)
|
#endif // defined(__APPLE__)
|
||||||
r_stat.st_blksize = static_cast<remote::block_size>(unix_st.st_blksize);
|
r_stat.st_blksize = static_cast<remote::block_size>(unix_st.st_blksize);
|
||||||
r_stat.st_blocks = static_cast<remote::block_count>(unix_st.st_blocks);
|
r_stat.st_blocks = static_cast<remote::block_count>(unix_st.st_blocks);
|
||||||
@ -406,16 +413,18 @@ auto remote_server::fuse_fsetattr_x(
|
|||||||
if (SETATTR_WANTS_MODTIME(&attr)) {
|
if (SETATTR_WANTS_MODTIME(&attr)) {
|
||||||
struct timeval val[2];
|
struct timeval val[2];
|
||||||
if (SETATTR_WANTS_ACCTIME(&attr)) {
|
if (SETATTR_WANTS_ACCTIME(&attr)) {
|
||||||
val[0U].tv_sec = static_cast<time_t>(attr.acctime / NANOS_PER_SECOND);
|
val[0U].tv_sec =
|
||||||
val[0U].tv_usec =
|
static_cast<time_t>(attr.acctime / utils::time::NANOS_PER_SECOND);
|
||||||
static_cast<time_t>((attr.acctime % NANOS_PER_SECOND) / 1000);
|
val[0U].tv_usec = static_cast<time_t>(
|
||||||
|
(attr.acctime % utils::time::NANOS_PER_SECOND) / 1000);
|
||||||
} else {
|
} else {
|
||||||
gettimeofday(&val[0U], nullptr);
|
gettimeofday(&val[0U], nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
val[1U].tv_sec = static_cast<time_t>(attr.modtime / NANOS_PER_SECOND);
|
val[1U].tv_sec =
|
||||||
val[1U].tv_usec =
|
static_cast<time_t>(attr.modtime / utils::time::NANOS_PER_SECOND);
|
||||||
static_cast<time_t>((attr.modtime % NANOS_PER_SECOND) / 1000);
|
val[1U].tv_usec = static_cast<time_t>(
|
||||||
|
(attr.modtime % utils::time::NANOS_PER_SECOND) / 1000);
|
||||||
|
|
||||||
res = utimes(file_path.c_str(), &val[0U]);
|
res = utimes(file_path.c_str(), &val[0U]);
|
||||||
}
|
}
|
||||||
@ -950,10 +959,10 @@ auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize,
|
|||||||
r_stat.f_blocks ? (r_stat.f_blocks - used_blocks) : 0;
|
r_stat.f_blocks ? (r_stat.f_blocks - used_blocks) : 0;
|
||||||
r_stat.f_ffree = r_stat.f_favail =
|
r_stat.f_ffree = r_stat.f_favail =
|
||||||
r_stat.f_files - drive_.get_total_item_count();
|
r_stat.f_files - drive_.get_total_item_count();
|
||||||
std::memset(&r_stat.f_mntfromname[0U], 0, sizeof(r_stat.f_mntfromname));
|
std::memset(r_stat.f_mntfromname.data(), 0, r_stat.f_mntfromname.data());
|
||||||
strncpy(&r_stat.f_mntfromname[0U],
|
strncpy(r_stat.f_mntfromname.data(),
|
||||||
(utils::create_volume_label(config_.get_provider_type())).c_str(),
|
(utils::create_volume_label(config_.get_provider_type())).c_str(),
|
||||||
sizeof(r_stat.f_mntfromname) - 1U);
|
r_stat.f_mntfromname.size() - 1U);
|
||||||
|
|
||||||
RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, 0);
|
RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, 0);
|
||||||
return 0;
|
return 0;
|
||||||
@ -998,16 +1007,20 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
|
|||||||
tv2[0U].tv_nsec = static_cast<time_t>(op0);
|
tv2[0U].tv_nsec = static_cast<time_t>(op0);
|
||||||
tv2[0U].tv_sec = 0;
|
tv2[0U].tv_sec = 0;
|
||||||
} else {
|
} else {
|
||||||
tv2[0U].tv_nsec = static_cast<time_t>(tv[0U] % NANOS_PER_SECOND);
|
tv2[0U].tv_nsec =
|
||||||
tv2[0U].tv_sec = static_cast<time_t>(tv[0U] / NANOS_PER_SECOND);
|
static_cast<time_t>(tv[0U] % utils::time::NANOS_PER_SECOND);
|
||||||
|
tv2[0U].tv_sec =
|
||||||
|
static_cast<time_t>(tv[0U] / utils::time::NANOS_PER_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((op1 == UTIME_NOW) || (op1 == UTIME_OMIT)) {
|
if ((op1 == UTIME_NOW) || (op1 == UTIME_OMIT)) {
|
||||||
tv2[1U].tv_nsec = static_cast<time_t>(op1);
|
tv2[1U].tv_nsec = static_cast<time_t>(op1);
|
||||||
tv2[1U].tv_sec = 0;
|
tv2[1U].tv_sec = 0;
|
||||||
} else {
|
} else {
|
||||||
tv2[1U].tv_nsec = static_cast<time_t>(tv[1U] % NANOS_PER_SECOND);
|
tv2[1U].tv_nsec =
|
||||||
tv2[1U].tv_sec = static_cast<time_t>(tv[1U] / NANOS_PER_SECOND);
|
static_cast<time_t>(tv[1U] % utils::time::NANOS_PER_SECOND);
|
||||||
|
tv2[1U].tv_sec =
|
||||||
|
static_cast<time_t>(tv[1U] / utils::time::NANOS_PER_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto res =
|
const auto res =
|
||||||
|
@ -745,9 +745,9 @@ auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize,
|
|||||||
r_stat.f_files = 4294967295;
|
r_stat.f_files = 4294967295;
|
||||||
r_stat.f_ffree = r_stat.f_favail =
|
r_stat.f_ffree = r_stat.f_favail =
|
||||||
r_stat.f_files - drive_.get_total_item_count();
|
r_stat.f_files - drive_.get_total_item_count();
|
||||||
strncpy(&r_stat.f_mntfromname[0U],
|
strncpy(r_stat.f_mntfromname.data(),
|
||||||
(utils::create_volume_label(config_.get_provider_type())).c_str(),
|
(utils::create_volume_label(config_.get_provider_type())).c_str(),
|
||||||
sizeof(r_stat.f_mntfromname) - 1U);
|
r_stat.f_mntfromname.size() - 1U);
|
||||||
|
|
||||||
RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, file_path, 0);
|
RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, file_path, 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -90,14 +90,17 @@ auto encrypt_provider::create_api_file(
|
|||||||
source_path);
|
source_path);
|
||||||
file.source_path = source_path;
|
file.source_path = source_path;
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
file.changed_date =
|
file.changed_date = buf.st_ctimespec.tv_nsec +
|
||||||
buf.st_ctimespec.tv_nsec + (buf.st_ctimespec.tv_sec * NANOS_PER_SECOND);
|
(buf.st_ctimespec.tv_sec * utils::time::NANOS_PER_SECOND);
|
||||||
file.accessed_date =
|
file.accessed_date =
|
||||||
buf.st_atimespec.tv_nsec + (buf.st_atimespec.tv_sec * NANOS_PER_SECOND);
|
buf.st_atimespec.tv_nsec +
|
||||||
file.creation_date = buf.st_birthtimespec.tv_nsec +
|
(buf.st_atimespec.tv_sec * utils::time::NANOS_PER_SECOND);
|
||||||
(buf.st_birthtimespec.tv_sec * NANOS_PER_SECOND);
|
file.creation_date =
|
||||||
|
buf.st_birthtimespec.tv_nsec +
|
||||||
|
(buf.st_birthtimespec.tv_sec * utils::time::NANOS_PER_SECOND);
|
||||||
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 * utils::time::NANOS_PER_SECOND);
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
file.accessed_date = utils::time::windows_time_to_unix_time(
|
file.accessed_date = utils::time::windows_time_to_unix_time(
|
||||||
static_cast<std::uint64_t>(buf.st_atime));
|
static_cast<std::uint64_t>(buf.st_atime));
|
||||||
@ -109,13 +112,17 @@ auto encrypt_provider::create_api_file(
|
|||||||
static_cast<std::uint64_t>(buf.st_mtime));
|
static_cast<std::uint64_t>(buf.st_mtime));
|
||||||
#else // !defined(_WIN32)
|
#else // !defined(_WIN32)
|
||||||
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 * utils::time::NANOS_PER_SECOND));
|
||||||
file.accessed_date = static_cast<std::uint64_t>(
|
file.accessed_date = static_cast<std::uint64_t>(
|
||||||
buf.st_atim.tv_nsec + (buf.st_atim.tv_sec * NANOS_PER_SECOND));
|
buf.st_atim.tv_nsec +
|
||||||
|
(buf.st_atim.tv_sec * utils::time::NANOS_PER_SECOND));
|
||||||
file.creation_date = static_cast<std::uint64_t>(
|
file.creation_date = static_cast<std::uint64_t>(
|
||||||
buf.st_ctim.tv_nsec + (buf.st_ctim.tv_sec * NANOS_PER_SECOND));
|
buf.st_ctim.tv_nsec +
|
||||||
|
(buf.st_ctim.tv_sec * utils::time::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 * utils::time::NANOS_PER_SECOND));
|
||||||
#endif // defined(__APPLE__)
|
#endif // defined(__APPLE__)
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
@ -218,12 +218,13 @@ auto get_directory_files(std::string path, bool oldest_first,
|
|||||||
stat(lookup_path.c_str(), &st);
|
stat(lookup_path.c_str(), &st);
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
lookup[lookup_path] = static_cast<std::uint64_t>(
|
lookup[lookup_path] = static_cast<std::uint64_t>(
|
||||||
(st.st_mtimespec.tv_sec * NANOS_PER_SECOND) +
|
(st.st_mtimespec.tv_sec * utils::time::NANOS_PER_SECOND) +
|
||||||
st.st_mtimespec.tv_nsec);
|
st.st_mtimespec.tv_nsec);
|
||||||
#else
|
#else // !defined(__APPLE__)
|
||||||
lookup[lookup_path] = static_cast<std::uint64_t>(
|
lookup[lookup_path] = static_cast<std::uint64_t>(
|
||||||
(st.st_mtim.tv_sec * NANOS_PER_SECOND) + st.st_mtim.tv_nsec);
|
(st.st_mtim.tv_sec * utils::time::NANOS_PER_SECOND) +
|
||||||
#endif
|
st.st_mtim.tv_nsec);
|
||||||
|
#endif // defined(__APPLE__)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -238,72 +239,15 @@ auto get_directory_files(std::string path, bool oldest_first,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_accessed_time(const std::string &path,
|
auto is_modified_date_older_than(std::string_view path,
|
||||||
std::uint64_t &accessed) -> bool {
|
|
||||||
auto ret = false;
|
|
||||||
accessed = 0;
|
|
||||||
#if defined(_WIN32)
|
|
||||||
struct _stat64 st {};
|
|
||||||
if (_stat64(path.c_str(), &st) != -1) {
|
|
||||||
accessed = time::windows_time_to_unix_time(
|
|
||||||
static_cast<std::uint64_t>(st.st_atime));
|
|
||||||
#else
|
|
||||||
struct stat st {};
|
|
||||||
if (stat(path.c_str(), &st) != -1) {
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
accessed = static_cast<uint64_t>(
|
|
||||||
st.st_atimespec.tv_nsec + (st.st_atimespec.tv_sec * NANOS_PER_SECOND));
|
|
||||||
#else
|
|
||||||
accessed = static_cast<uint64_t>(st.st_atim.tv_nsec +
|
|
||||||
(st.st_atim.tv_sec * NANOS_PER_SECOND));
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto get_modified_time(const std::string &path,
|
|
||||||
std::uint64_t &modified) -> bool {
|
|
||||||
auto ret = false;
|
|
||||||
modified = 0U;
|
|
||||||
#if defined(_WIN32)
|
|
||||||
struct _stat64 st {};
|
|
||||||
if (_stat64(path.c_str(), &st) != -1) {
|
|
||||||
modified = time::windows_time_to_unix_time(
|
|
||||||
static_cast<std::uint64_t>(st.st_mtime));
|
|
||||||
#else
|
|
||||||
struct stat st {};
|
|
||||||
if (stat(path.c_str(), &st) != -1) {
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
modified = static_cast<uint64_t>(
|
|
||||||
st.st_mtimespec.tv_nsec + (st.st_mtimespec.tv_sec * NANOS_PER_SECOND));
|
|
||||||
#else
|
|
||||||
modified = static_cast<uint64_t>(st.st_mtim.tv_nsec +
|
|
||||||
(st.st_mtim.tv_sec * NANOS_PER_SECOND));
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto is_modified_date_older_than(const std::string &path,
|
|
||||||
const std::chrono::hours &hours) -> bool {
|
const std::chrono::hours &hours) -> bool {
|
||||||
auto ret = false;
|
auto modified = file{path}.get_time(file::time_types::modified);
|
||||||
std::uint64_t modified{};
|
|
||||||
if (get_modified_time(path, modified)) {
|
|
||||||
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(hours);
|
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(hours);
|
||||||
return (modified +
|
return (modified + static_cast<std::uint64_t>(
|
||||||
static_cast<std::uint64_t>(seconds.count() * NANOS_PER_SECOND)) <
|
seconds.count() * utils::time::NANOS_PER_SECOND)) <
|
||||||
utils::time::get_time_now();
|
utils::time::get_time_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto move_file(std::string from, std::string to) -> bool {
|
auto move_file(std::string from, std::string to) -> bool {
|
||||||
from = utils::path::absolute(from);
|
from = utils::path::absolute(from);
|
||||||
to = utils::path::absolute(to);
|
to = utils::path::absolute(to);
|
||||||
|
@ -219,13 +219,13 @@ static void fgetattr_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_EQ(st1.st_nlink, st.st_nlink);
|
EXPECT_EQ(st1.st_nlink, st.st_nlink);
|
||||||
EXPECT_EQ(st1.st_mode, st.st_mode);
|
EXPECT_EQ(st1.st_mode, st.st_mode);
|
||||||
EXPECT_LE(static_cast<remote::file_time>(st1.st_atime),
|
EXPECT_LE(static_cast<remote::file_time>(st1.st_atime),
|
||||||
st.st_atimespec / NANOS_PER_SECOND);
|
st.st_atimespec / utils::time::NANOS_PER_SECOND);
|
||||||
EXPECT_EQ(static_cast<remote::file_time>(st1.st_mtime),
|
EXPECT_EQ(static_cast<remote::file_time>(st1.st_mtime),
|
||||||
st.st_mtimespec / NANOS_PER_SECOND);
|
st.st_mtimespec / utils::time::NANOS_PER_SECOND);
|
||||||
EXPECT_EQ(static_cast<remote::file_time>(st1.st_ctime),
|
EXPECT_EQ(static_cast<remote::file_time>(st1.st_ctime),
|
||||||
st.st_ctimespec / NANOS_PER_SECOND);
|
st.st_ctimespec / utils::time::NANOS_PER_SECOND);
|
||||||
EXPECT_EQ(static_cast<remote::file_time>(st1.st_ctime),
|
EXPECT_EQ(static_cast<remote::file_time>(st1.st_ctime),
|
||||||
st.st_birthtimespec / NANOS_PER_SECOND);
|
st.st_birthtimespec / utils::time::NANOS_PER_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::file(test_file).remove());
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
@ -330,13 +330,13 @@ static void getattr_test(repertory::remote_fuse::remote_client &client) {
|
|||||||
EXPECT_EQ(st1.st_nlink, st.st_nlink);
|
EXPECT_EQ(st1.st_nlink, st.st_nlink);
|
||||||
EXPECT_EQ(st1.st_mode, st.st_mode);
|
EXPECT_EQ(st1.st_mode, st.st_mode);
|
||||||
EXPECT_LE(static_cast<remote::file_time>(st1.st_atime),
|
EXPECT_LE(static_cast<remote::file_time>(st1.st_atime),
|
||||||
st.st_atimespec / NANOS_PER_SECOND);
|
st.st_atimespec / utils::time::NANOS_PER_SECOND);
|
||||||
EXPECT_EQ(static_cast<remote::file_time>(st1.st_mtime),
|
EXPECT_EQ(static_cast<remote::file_time>(st1.st_mtime),
|
||||||
st.st_mtimespec / NANOS_PER_SECOND);
|
st.st_mtimespec / utils::time::NANOS_PER_SECOND);
|
||||||
EXPECT_EQ(static_cast<remote::file_time>(st1.st_ctime),
|
EXPECT_EQ(static_cast<remote::file_time>(st1.st_ctime),
|
||||||
st.st_ctimespec / NANOS_PER_SECOND);
|
st.st_ctimespec / utils::time::NANOS_PER_SECOND);
|
||||||
EXPECT_EQ(static_cast<remote::file_time>(st1.st_ctime),
|
EXPECT_EQ(static_cast<remote::file_time>(st1.st_ctime),
|
||||||
st.st_birthtimespec / NANOS_PER_SECOND);
|
st.st_birthtimespec / utils::time::NANOS_PER_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_TRUE(utils::file::file(test_file).remove());
|
EXPECT_TRUE(utils::file::file(test_file).remove());
|
||||||
@ -832,7 +832,7 @@ static void statfs_x_test(repertory::remote_fuse::remote_client &client,
|
|||||||
|
|
||||||
remote::statfs_x st{};
|
remote::statfs_x st{};
|
||||||
EXPECT_EQ(0, client.fuse_statfs_x(api_path.c_str(), 4096, st));
|
EXPECT_EQ(0, client.fuse_statfs_x(api_path.c_str(), 4096, st));
|
||||||
EXPECT_STREQ(&st.f_mntfromname[0],
|
EXPECT_STREQ(st.f_mntfromname.data(),
|
||||||
utils::create_volume_label(provider_type::remote).c_str());
|
utils::create_volume_label(provider_type::remote).c_str());
|
||||||
|
|
||||||
const auto total_bytes = drive.get_total_drive_space();
|
const auto total_bytes = drive.get_total_drive_space();
|
||||||
|
Reference in New Issue
Block a user