diff --git a/support/src/utils/file.cpp b/support/src/utils/file.cpp index 18ed5c14..ced2f49c 100644 --- a/support/src/utils/file.cpp +++ b/support/src/utils/file.cpp @@ -50,6 +50,8 @@ auto get_times(std::string_view path) -> std::optional { }; try { + file_times ret{}; + #if defined(_WIN32) auto file_handle = ::CreateFileA(std::string{path}.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, 0, nullptr); @@ -69,46 +71,32 @@ auto get_times(std::string_view path) -> std::optional { '|' + std::to_string(utils::get_last_error_code())); } + + 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) 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(errno)); } -#endif // defined(_WIN32) - file_times ret{}; -#if defined(_WIN32) - ret.accessed = utils::time::windows_file_time_to_unix_time(times.at(1U)); -#else // !defined(_WIN32) ret.accessed = static_cast(st.st_atim.tv_nsec) + static_cast(st.st_atim.tv_sec) * utils::time::NANOS_PER_SECOND; -#endif // defined(_WIN32) - -#if defined(_WIN32) - ret.created = utils::time::windows_file_time_to_unix_time(times.at(0U)); -#else // !defined(_WIN32) ret.created = static_cast(st.st_ctim.tv_nsec) + static_cast(st.st_ctim.tv_sec) * utils::time::NANOS_PER_SECOND; -#endif // defined(_WIN32) - -#if defined(_WIN32) - ret.modified = utils::time::windows_file_time_to_unix_time(times.at(2U)); -#else // !defined(_WIN32) ret.modified = static_cast(st.st_mtim.tv_nsec) + static_cast(st.st_mtim.tv_sec) * utils::time::NANOS_PER_SECOND; -#endif // defined(_WIN32) - -#if defined(_WIN32) - ret.written = utils::time::windows_file_time_to_unix_time(times.at(2U)); -#else // !defined(_WIN32) ret.written = static_cast(st.st_mtim.tv_nsec) + static_cast(st.st_mtim.tv_sec) * utils::time::NANOS_PER_SECOND; #endif // defined(_WIN32) + return ret; } catch (const std::exception &e) { utils::error::handle_exception(function_name, e); diff --git a/support/src/utils/file_directory.cpp b/support/src/utils/file_directory.cpp index 09c699b3..a62a989b 100644 --- a/support/src/utils/file_directory.cpp +++ b/support/src/utils/file_directory.cpp @@ -95,7 +95,8 @@ auto directory::copy_to(std::string_view new_path, try { throw std::runtime_error("failed to copy directory|" + path_ + '|' + - std::string{new_path} + "|not implemented"); + std::string{new_path} + '+' + + std::to_string(overwrite) + "|not implemented"); } catch (const std::exception &e) { utils::error::handle_exception(function_name, e); } catch (...) {