updated build system
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2024-08-30 14:08:39 -05:00
parent a22a92abc0
commit 561cfd937a
7 changed files with 89 additions and 33 deletions

View File

@ -1,18 +1,18 @@
set(BINUTILS_VERSION 2.41)
set(BOOST_MAJOR_VERSION 1)
set(BOOST_MINOR_VERSION 85)
set(BOOST_PATCH_VERSION 0)
set(BOOST2_MAJOR_VERSION 1)
set(BOOST2_MINOR_VERSION 76)
set(BOOST2_PATCH_VERSION 0)
set(BOOST_MAJOR_VERSION 1)
set(BOOST_MINOR_VERSION 85)
set(BOOST_PATCH_VERSION 0)
set(CLI11_VERSION 2.4.2)
set(CPP_HTTPLIB_VERSION 0.16.3)
set(CURL_VERSION 8.9.1)
set(CURL2_VERSION 8_9_1)
set(CURL_VERSION 8.9.1)
set(CXXOPTS_VERSION 3.2.1)
set(DTL_VERSION 2.01)
set(EXPAT_VERSION 2.6.2)
set(EXPAT2_VERSION 2_6_2)
set(EXPAT_VERSION 2.6.2)
set(FLAC_VERSION 1.4.3)
set(FMT_VERSION 11.0.2)
set(FONTCONFIG_VERSION 2.15.0)
@ -44,8 +44,8 @@ set(SDL_VERSION 2.30.6)
set(SECP256K1_VERSION 0.1.0.20)
set(SFML_VERSION 2.6.1)
set(SPDLOG_VERSION 1.14.1)
set(SQLITE_VERSION 3460100)
set(SQLITE2_VERSION 3.46.1)
set(SQLITE_VERSION 3460100)
set(STDUUID_VERSION 1.2.3)
set(VLC_VERSION 3.0)
set(VORBIS_VERSION 1.3.7)

View File

@ -52,6 +52,9 @@ auto strptime(const char *s, const char *f, struct tm *tm) -> const char *;
[[nodiscard]] auto unix_time_to_filetime(std::uint64_t unix_time) -> FILETIME;
[[nodiscard]] auto
windows_file_time_to_unix_time(FILETIME win_time) -> std::uint64_t;
[[nodiscard]] auto
windows_time_t_to_unix_time(__time64_t win_time) -> std::uint64_t;
#endif // defined(_WIN32)

View File

@ -26,6 +26,7 @@
#include "utils/path.hpp"
#include "utils/string.hpp"
#include "utils/time.hpp"
#include "utils/windows.hpp"
namespace repertory::utils::file {
auto get_time(std::string_view path,
@ -50,46 +51,64 @@ auto get_times(std::string_view path) -> std::optional<file_times> {
try {
#if defined(_WIN32)
struct _stat64 st {};
auto res = _stat64(std::string{path}.c_str(), &st);
auto file_handle = ::CreateFileA(std::string{path}.c_str(), GENERIC_READ, 0,
nullptr, OPEN_EXISTING, 0, 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()));
}
std::array<FILETIME, 3U> times{};
auto res =
::GetFileTime(file_handle, &times.at(0U), &times.at(1U), &times.at(2U));
::CloseHandle(file_handle);
if (not res) {
throw std::runtime_error("failed to get file times|" + std::string{path} +
'|' +
std::to_string(utils::get_last_error_code()));
}
#else // !defined(_WIN32)
struct stat st {};
auto res = stat(std::string{path}.c_str(), &st);
#endif // defined(_WIN32)
if (res != 0) {
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_time_t_to_unix_time(st.st_atime);
ret.accessed = utils::time::windows_file_time_to_unix_time(times.at(1U));
#else // !defined(_WIN32)
ret.accessed = static_cast<std::uint64_t>(
st.st_atim.tv_nsec + st.st_atim.tv_sec * utils::time::NANOS_PER_SECOND);
ret.accessed = static_cast<std::uint64_t>(st.st_atim.tv_nsec) +
static_cast<std::uint64_t>(st.st_atim.tv_sec) *
utils::time::NANOS_PER_SECOND;
#endif // defined(_WIN32)
#if defined(_WIN32)
ret.created = utils::time::windows_time_t_to_unix_time(st.st_ctime);
ret.created = utils::time::windows_file_time_to_unix_time(times.at(0U));
#else // !defined(_WIN32)
ret.created = static_cast<std::uint64_t>(
st.st_ctim.tv_nsec + st.st_ctim.tv_sec * utils::time::NANOS_PER_SECOND);
ret.created = static_cast<std::uint64_t>(st.st_ctim.tv_nsec) +
static_cast<std::uint64_t>(st.st_ctim.tv_sec) *
utils::time::NANOS_PER_SECOND;
#endif // defined(_WIN32)
#if defined(_WIN32)
ret.modified = utils::time::windows_time_t_to_unix_time(st.st_mtime);
ret.modified = utils::time::windows_file_time_to_unix_time(times.at(2U));
#else // !defined(_WIN32)
ret.modified = static_cast<std::uint64_t>(
st.st_mtim.tv_nsec + st.st_mtim.tv_sec * utils::time::NANOS_PER_SECOND);
ret.modified = 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)
#if defined(_WIN32)
ret.written = utils::time::windows_time_t_to_unix_time(st.st_mtime);
ret.written = utils::time::windows_file_time_to_unix_time(times.at(2U));
#else // !defined(_WIN32)
ret.written = static_cast<std::uint64_t>(
st.st_mtim.tv_nsec + st.st_mtim.tv_sec * utils::time::NANOS_PER_SECOND);
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;
} catch (const std::exception &e) {
utils::error::handle_exception(function_name, e);

View File

@ -89,6 +89,19 @@ auto traverse_directory(
namespace repertory::utils::file {
auto directory::copy_to(std::string_view new_path,
bool overwrite) const -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
try {
throw std::runtime_error("failed to copy directory|" + path_ + '|' +
std::string{new_path} + "|not implemented");
} catch (const std::exception &e) {
utils::error::handle_exception(function_name, e);
} catch (...) {
utils::error::handle_exception(function_name);
}
return false;
}
@ -177,8 +190,8 @@ auto directory::exists() const -> bool {
#if defined(_WIN32)
return ::PathIsDirectoryA(path_.c_str()) != 0;
#else // !defined(_WIN32)
struct stat st {};
return (stat(path_.c_str(), &st) == 0 && S_ISDIR(st.st_mode));
struct stat64 st {};
return (stat64(path_.c_str(), &st) == 0 && S_ISDIR(st.st_mode));
#endif // defined(_WIN32)
return false;
@ -345,7 +358,22 @@ auto directory::is_symlink() const -> bool {
return false;
}
auto directory::move_to(std::string_view new_path) -> bool { return false; }
auto directory::move_to(std::string_view new_path) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
try {
throw std::runtime_error("failed to move directory|" + path_ + '|' +
std::string{new_path} + "|not implemented");
} catch (const std::exception &e) {
utils::error::handle_exception(function_name, e);
} catch (...) {
utils::error::handle_exception(function_name);
}
return false;
}
auto directory::remove() -> bool {
static constexpr const std::string_view function_name{

View File

@ -55,8 +55,8 @@ namespace {
return (::PathFileExistsA(abs_path.c_str()) &&
not ::PathIsDirectoryA(abs_path.c_str()));
#else // !defined(_WIN32)
struct stat st {};
return (stat(abs_path.c_str(), &st) == 0 && not S_ISDIR(st.st_mode));
struct stat64 st {};
return (stat64(abs_path.c_str(), &st) == 0 && not S_ISDIR(st.st_mode));
#endif // defined(_WIN32)
}
} // namespace

View File

@ -118,16 +118,16 @@ auto smb_file::get_time(smb_session *session, smb_tid tid, std::string path,
}
switch (type) {
case time_type::access:
case time_type::accessed:
return smb_stat_get(st.get(), SMB_STAT_ATIME);
case time_type::creation:
case time_type::created:
return smb_stat_get(st.get(), SMB_STAT_CTIME);
case time_type::modified:
return smb_stat_get(st.get(), SMB_STAT_MTIME);
case time_type::write:
case time_type::written:
return smb_stat_get(st.get(), SMB_STAT_WTIME);
}
} catch (const std::exception &e) {

View File

@ -64,6 +64,12 @@ auto unix_time_to_filetime(std::uint64_t unix_time) -> FILETIME {
return file_time;
}
auto windows_file_time_to_unix_time(FILETIME win_time) -> std::uint64_t {
return windows_time_to_unix_time(
(static_cast<std::uint64_t>(win_time.dwHighDateTime) << 32ULL) |
static_cast<std::uint64_t>(win_time.dwLowDateTime));
}
auto windows_time_t_to_unix_time(__time64_t win_time) -> std::uint64_t {
return static_cast<std::uint64_t>(
std::chrono::duration_cast<std::chrono::nanoseconds>(