Compare commits
3 Commits
a7239558bd
...
4aad60f69d
Author | SHA1 | Date | |
---|---|---|---|
4aad60f69d | |||
72f7aaf9e4 | |||
d12b5f7b05 |
@ -28,7 +28,7 @@
|
||||
|
||||
namespace repertory {
|
||||
// clang-format off
|
||||
E_SIMPLE2(curl_error, info, true,
|
||||
E_SIMPLE2(curl_error, error, true,
|
||||
std::string, url, url, E_STRING,
|
||||
CURLcode, res, res, E_FROM_CURL_CODE
|
||||
);
|
||||
@ -109,7 +109,7 @@ E_SIMPLE3(file_read_bytes_failed, error, true,
|
||||
std::size_t, retry, retry, E_FROM_SIZE_T
|
||||
);
|
||||
|
||||
E_SIMPLE1(file_removed, info, true,
|
||||
E_SIMPLE1(file_removed, debug, true,
|
||||
std::string, api_path, ap, E_STRING
|
||||
);
|
||||
|
||||
@ -134,7 +134,7 @@ E_SIMPLE2(file_get_size_failed, error, true,
|
||||
std::string, error, err, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE3(filesystem_item_added, info, true,
|
||||
E_SIMPLE3(filesystem_item_added, debug, true,
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, parent, parent, E_STRING,
|
||||
bool, directory, dir, E_FROM_BOOL
|
||||
@ -167,11 +167,6 @@ E_SIMPLE2(filesystem_item_evicted, info, true,
|
||||
std::string, source, src, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE2(filesystem_item_get_failed, error, true,
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, error, err, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE3(filesystem_item_opened, trace, true,
|
||||
std::string, api_path, ap, E_STRING,
|
||||
std::string, source, src, E_STRING,
|
||||
@ -220,10 +215,6 @@ E_SIMPLE2(file_upload_started, info, true,
|
||||
std::string, source, src, E_STRING
|
||||
);
|
||||
|
||||
E_SIMPLE(item_scan_begin, info, true);
|
||||
|
||||
E_SIMPLE(item_scan_end, info, true);
|
||||
|
||||
E_SIMPLE1(orphaned_file_deleted, warn, true,
|
||||
std::string, source, src, E_STRING
|
||||
);
|
||||
|
@ -176,32 +176,37 @@ auto get_times(std::string_view path) -> std::optional<file_times> {
|
||||
file_times ret{};
|
||||
|
||||
#if defined(_WIN32)
|
||||
auto file_handle =
|
||||
::CreateFileA(std::string{path}.c_str(), GENERIC_READ,
|
||||
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
nullptr, OPEN_EXISTING, 0U, nullptr);
|
||||
if (file_handle == INVALID_HANDLE_VALUE) {
|
||||
throw std::runtime_error("failed to get file times|" + std::string{path} +
|
||||
'|' +
|
||||
std::to_string(utils::get_last_error_code()));
|
||||
auto file_handle = ::CreateFileA(
|
||||
std::string{path}.c_str(), GENERIC_READ,
|
||||
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
|
||||
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
|
||||
if (file_handle != INVALID_HANDLE_VALUE) {
|
||||
std::array<FILETIME, 3U> times{};
|
||||
auto res = ::GetFileTime(file_handle, ×.at(0U), ×.at(1U),
|
||||
×.at(2U));
|
||||
::CloseHandle(file_handle);
|
||||
if (res) {
|
||||
ret.accessed =
|
||||
utils::time::windows_file_time_to_unix_time(times.at(1U));
|
||||
ret.created = utils::time::windows_file_time_to_unix_time(times.at(0U));
|
||||
ret.modified =
|
||||
utils::time::windows_file_time_to_unix_time(times.at(2U));
|
||||
ret.written = utils::time::windows_file_time_to_unix_time(times.at(2U));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
std::array<FILETIME, 3U> times{};
|
||||
auto res =
|
||||
::GetFileTime(file_handle, ×.at(0U), ×.at(1U), ×.at(2U));
|
||||
::CloseHandle(file_handle);
|
||||
|
||||
if (not res) {
|
||||
struct _stat64 st {};
|
||||
if (_stat64(std::string{path}.c_str(), &st) != 0) {
|
||||
throw std::runtime_error("failed to get file times|" + std::string{path} +
|
||||
'|' +
|
||||
std::to_string(utils::get_last_error_code()));
|
||||
'|' + std::to_string(errno));
|
||||
}
|
||||
|
||||
ret.accessed = utils::time::windows_file_time_to_unix_time(times.at(1U));
|
||||
ret.created = utils::time::windows_file_time_to_unix_time(times.at(0U));
|
||||
ret.modified = utils::time::windows_file_time_to_unix_time(times.at(2U));
|
||||
ret.written = utils::time::windows_file_time_to_unix_time(times.at(2U));
|
||||
#else // !defined(_WIN32)
|
||||
ret.accessed = utils::time::windows_time_t_to_unix_time(st.st_atime);
|
||||
ret.created = utils::time::windows_time_t_to_unix_time(st.st_ctime);
|
||||
ret.modified = utils::time::windows_time_t_to_unix_time(st.st_mtime);
|
||||
ret.written = utils::time::windows_time_t_to_unix_time(st.st_mtime);
|
||||
#else // !defined(_WIN32)
|
||||
struct stat64 st {};
|
||||
if (stat64(std::string{path}.c_str(), &st) != 0) {
|
||||
throw std::runtime_error("failed to get file times|" + std::string{path} +
|
||||
@ -220,6 +225,7 @@ auto get_times(std::string_view path) -> std::optional<file_times> {
|
||||
ret.written = static_cast<std::uint64_t>(st.st_mtim.tv_nsec) +
|
||||
static_cast<std::uint64_t>(st.st_mtim.tv_sec) *
|
||||
utils::time::NANOS_PER_SECOND;
|
||||
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user