updated build system

This commit is contained in:
2024-10-17 10:20:07 -05:00
parent 39d644e115
commit 63ca3089da
22 changed files with 304 additions and 198 deletions

View File

@@ -33,7 +33,7 @@ namespace {
file_size = 0U;
#if defined(_WIN32)
struct _stat64 st {};
struct _stat64 st{};
auto res = _stat64(std::string{path}.c_str(), &st);
if (res != 0) {
return false;
@@ -52,10 +52,10 @@ namespace {
auto abs_path = repertory::utils::path::absolute(path);
#if defined(_WIN32)
return (::PathFileExistsA(abs_path.c_str()) &&
not ::PathIsDirectoryA(abs_path.c_str()));
return ((::PathFileExistsA(abs_path.c_str()) != 0) &&
(::PathIsDirectoryA(abs_path.c_str()) == 0));
#else // !defined(_WIN32)
struct stat64 st {};
struct stat64 st{};
return (stat64(abs_path.c_str(), &st) == 0 && not S_ISDIR(st.st_mode));
#endif // defined(_WIN32)
}
@@ -119,11 +119,15 @@ void file::open() {
}
#if defined(_WIN32)
file_ = file_t(_fsopen(path_.c_str(), read_only_ ? "rb" : "rb+", _SH_DENYNO),
file_deleter());
file_ = file_t{
_fsopen(path_.c_str(), read_only_ ? "rb" : "rb+", _SH_DENYNO),
file_deleter(),
};
#else // !defined(_WIN32)
file_ =
file_t(fopen(path_.c_str(), read_only_ ? "rb" : "rb+"), file_deleter());
file_ = file_t{
fopen(path_.c_str(), read_only_ ? "rb" : "rb+"),
file_deleter(),
};
#endif // defined(_WIN32)
}
@@ -150,8 +154,8 @@ auto file::open_file(std::string_view path, bool read_only) -> fs_file_t {
return new_file;
}
auto file::open_or_create_file(std::string_view path,
bool read_only) -> fs_file_t {
auto file::open_or_create_file(std::string_view path, bool read_only)
-> fs_file_t {
auto abs_path = utils::path::absolute(path);
if (not is_file(abs_path)) {
#if defined(_WIN32)
@@ -196,7 +200,7 @@ auto file::copy_to(std::string_view new_path, bool overwrite) const -> bool {
#if defined(_WIN32)
return ::CopyFileA(path_.c_str(), to_path.c_str(),
overwrite ? TRUE : FALSE);
overwrite ? TRUE : FALSE) != 0;
#else // !defined(_WIN32)
return std::filesystem::copy_file(
path_, to_path,
@@ -264,8 +268,8 @@ auto file::move_to(std::string_view path) -> bool {
auto success{false};
#if defined(_WIN32)
success = !!::MoveFileExA(path_.c_str(), abs_path.c_str(),
MOVEFILE_REPLACE_EXISTING);
success = ::MoveFileExA(path_.c_str(), abs_path.c_str(),
MOVEFILE_REPLACE_EXISTING) != 0;
#else // !// defined(_WIN32)
std::error_code ec{};
std::filesystem::rename(path_, abs_path, ec);
@@ -415,7 +419,7 @@ auto file::remove() -> bool {
return utils::retry_action([this]() -> bool {
#if defined(_WIN32)
return ::DeleteFileA(path_.c_str());
return ::DeleteFileA(path_.c_str()) != 0;
#else // !defined(_WIN32)
std::error_code ec{};
return std::filesystem::remove(path_, ec);