address windows compiler warnings
This commit is contained in:
parent
aafa7e112a
commit
63a6b3bdba
@ -30,9 +30,9 @@
|
||||
namespace repertory::utils::file {
|
||||
auto calculate_used_space(std::string path, bool recursive) -> std::uint64_t {
|
||||
path = utils::path::absolute(path);
|
||||
std::uint64_t ret = 0u;
|
||||
std::uint64_t ret{};
|
||||
#ifdef _WIN32
|
||||
WIN32_FIND_DATA fd = {0};
|
||||
WIN32_FIND_DATA fd{};
|
||||
const auto search = utils::path::combine(path, {"*.*"});
|
||||
auto find = ::FindFirstFile(search.c_str(), &fd);
|
||||
if (find != INVALID_HANDLE_VALUE) {
|
||||
@ -118,7 +118,7 @@ auto copy_directory_recursively(std::string from_path, std::string to_path)
|
||||
auto ret = create_full_directory_path(to_path);
|
||||
if (ret) {
|
||||
#ifdef _WIN32
|
||||
WIN32_FIND_DATA fd = {0};
|
||||
WIN32_FIND_DATA fd{};
|
||||
const auto search = utils::path::combine(from_path, {"*.*"});
|
||||
auto find = ::FindFirstFile(search.c_str(), &fd);
|
||||
if (find != INVALID_HANDLE_VALUE) {
|
||||
@ -209,7 +209,7 @@ auto delete_directory_recursively(std::string path) -> bool {
|
||||
path = utils::path::absolute(path);
|
||||
#ifdef _WIN32
|
||||
|
||||
WIN32_FIND_DATA fd = {0};
|
||||
WIN32_FIND_DATA fd{};
|
||||
const auto search = utils::path::combine(path, {"*.*"});
|
||||
auto find = ::FindFirstFile(search.c_str(), &fd);
|
||||
if (find != INVALID_HANDLE_VALUE) {
|
||||
@ -361,7 +361,7 @@ auto get_directory_files(std::string path, bool oldest_first, bool recursive)
|
||||
std::deque<std::string> ret;
|
||||
std::unordered_map<std::string, std::uint64_t> lookup;
|
||||
#ifdef _WIN32
|
||||
WIN32_FIND_DATA fd = {0};
|
||||
WIN32_FIND_DATA fd{};
|
||||
const auto search = utils::path::combine(path, {"*.*"});
|
||||
auto find = ::FindFirstFile(search.c_str(), &fd);
|
||||
if (find != INVALID_HANDLE_VALUE) {
|
||||
@ -531,13 +531,14 @@ auto is_file(const std::string &path) -> bool {
|
||||
auto is_modified_date_older_than(const std::string &path,
|
||||
const std::chrono::hours &hours) -> bool {
|
||||
auto ret = false;
|
||||
std::uint64_t modified = 0;
|
||||
std::uint64_t modified{};
|
||||
if (get_modified_time(path, modified)) {
|
||||
const auto seconds =
|
||||
std::chrono::duration_cast<std::chrono::seconds>(hours);
|
||||
#ifdef _WIN32
|
||||
return (std::chrono::system_clock::from_time_t(modified) + seconds) <
|
||||
std::chrono::system_clock::now();
|
||||
return (std::chrono::system_clock::from_time_t(
|
||||
static_cast<time_t>(modified)) +
|
||||
seconds) < std::chrono::system_clock::now();
|
||||
#else
|
||||
return (modified +
|
||||
static_cast<std::uint64_t>(seconds.count() * NANOS_PER_SECOND)) <
|
||||
|
@ -116,7 +116,7 @@ auto native_file::open(const std::string &source_path,
|
||||
auto native_file::allocate(std::uint64_t file_size) -> bool {
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER li{};
|
||||
li.QuadPart = file_size;
|
||||
li.QuadPart = static_cast<LONGLONG>(file_size);
|
||||
return (::SetFilePointerEx(handle_, li, nullptr, FILE_BEGIN) &&
|
||||
::SetEndOfFile(handle_));
|
||||
#endif
|
||||
@ -214,7 +214,7 @@ auto native_file::read_bytes(char *buffer, std::size_t read_size,
|
||||
auto ret = false;
|
||||
bytes_read = 0u;
|
||||
LARGE_INTEGER li{};
|
||||
li.QuadPart = read_offset;
|
||||
li.QuadPart = static_cast<LONGLONG>(read_offset);
|
||||
if ((ret = !!::SetFilePointerEx(handle_, li, nullptr, FILE_BEGIN))) {
|
||||
DWORD current_read = 0u;
|
||||
do {
|
||||
@ -253,7 +253,7 @@ auto native_file::truncate(std::uint64_t file_size) -> bool {
|
||||
#ifdef _WIN32
|
||||
recur_mutex_lock l(read_write_mutex_);
|
||||
LARGE_INTEGER li{};
|
||||
li.QuadPart = file_size;
|
||||
li.QuadPart = static_cast<LONGLONG>(file_size);
|
||||
return (::SetFilePointerEx(handle_, li, nullptr, FILE_BEGIN) &&
|
||||
::SetEndOfFile(handle_));
|
||||
#else
|
||||
@ -271,7 +271,7 @@ auto native_file::write_bytes(const char *buffer, std::size_t write_size,
|
||||
auto ret = true;
|
||||
|
||||
LARGE_INTEGER li{};
|
||||
li.QuadPart = write_offset;
|
||||
li.QuadPart = static_cast<LONGLONG>(write_offset);
|
||||
if ((ret = !!::SetFilePointerEx(handle_, li, nullptr, FILE_BEGIN))) {
|
||||
do {
|
||||
DWORD current_write = 0u;
|
||||
|
@ -170,16 +170,16 @@ auto download_type_to_string(const download_type &type) -> std::string {
|
||||
// https://www.frenk.com/2009/12/convert-filetime-to-unix-timestamp/
|
||||
auto filetime_to_unix_time(const FILETIME &ft) -> remote::file_time {
|
||||
LARGE_INTEGER date{};
|
||||
date.HighPart = ft.dwHighDateTime;
|
||||
date.HighPart = static_cast<LONG>(ft.dwHighDateTime);
|
||||
date.LowPart = ft.dwLowDateTime;
|
||||
date.QuadPart -= 116444736000000000ULL;
|
||||
date.QuadPart -= 116444736000000000LL;
|
||||
|
||||
return date.QuadPart * 100ULL;
|
||||
return static_cast<remote::file_time>(date.QuadPart) * 100ULL;
|
||||
}
|
||||
|
||||
void unix_time_to_filetime(const remote::file_time &ts, FILETIME &ft) {
|
||||
const auto win_time = (ts / 100ULL) + 116444736000000000ULL;
|
||||
ft.dwHighDateTime = win_time >> 32U;
|
||||
ft.dwHighDateTime = static_cast<DWORD>(win_time >> 32U);
|
||||
ft.dwLowDateTime = win_time & 0xFFFFFFFF;
|
||||
}
|
||||
#endif
|
||||
@ -216,7 +216,8 @@ auto get_file_time_now() -> std::uint64_t {
|
||||
::GetSystemTime(&st);
|
||||
FILETIME ft{};
|
||||
::SystemTimeToFileTime(&st, &ft);
|
||||
return static_cast<std::uint64_t>(((LARGE_INTEGER *)&ft)->QuadPart);
|
||||
return static_cast<std::uint64_t>(
|
||||
(reinterpret_cast<LARGE_INTEGER *>(&ft))->QuadPart);
|
||||
#else
|
||||
return get_time_now();
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#ifndef STATUS_DEVICE_INSUFFICIENT_RESOURCES
|
||||
#define STATUS_DEVICE_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC0000468L)
|
||||
#define STATUS_DEVICE_INSUFFICIENT_RESOURCES static_cast<NTSTATUS>(0xC0000468L)
|
||||
#endif
|
||||
|
||||
namespace repertory::utils {
|
||||
@ -95,9 +95,9 @@ auto get_local_app_data_directory() -> const std::string & {
|
||||
PWSTR local_app_data{};
|
||||
if (SUCCEEDED(::SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr,
|
||||
&local_app_data))) {
|
||||
auto app_data = utils::string::to_utf8(local_app_data);
|
||||
auto ret = utils::string::to_utf8(local_app_data);
|
||||
::CoTaskMemFree(local_app_data);
|
||||
return app_data;
|
||||
return ret;
|
||||
}
|
||||
|
||||
throw startup_exception("unable to detect local application data folder");
|
||||
@ -164,14 +164,14 @@ auto run_process_elevated(std::vector<const char *> args) -> int {
|
||||
sei.nShow = SW_NORMAL;
|
||||
if (::ShellExecuteEx(&sei)) {
|
||||
::WaitForSingleObject(sei.hProcess, INFINITE);
|
||||
DWORD exit_code = 0u;
|
||||
DWORD exit_code{};
|
||||
::GetExitCodeProcess(sei.hProcess, &exit_code);
|
||||
::CloseHandle(sei.hProcess);
|
||||
return exit_code;
|
||||
return static_cast<int>(exit_code);
|
||||
}
|
||||
}
|
||||
|
||||
return ::GetLastError();
|
||||
return static_cast<int>(::GetLastError());
|
||||
}
|
||||
|
||||
void set_last_error_code(DWORD error_code) { ::SetLastError(error_code); }
|
||||
@ -234,7 +234,7 @@ auto unix_open_flags_to_flags_and_perms(const remote::file_mode & /*mode*/,
|
||||
}
|
||||
|
||||
auto time64_to_unix_time(const __time64_t &t) -> remote::file_time {
|
||||
return t * NANOS_PER_SECOND;
|
||||
return static_cast<remote::file_time>(t * NANOS_PER_SECOND);
|
||||
}
|
||||
} // namespace repertory::utils
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user