winfsp unit tests and fixes
This commit is contained in:
@ -37,7 +37,7 @@ auto change_to_process_directory() -> bool {
|
||||
try {
|
||||
#if defined(_WIN32)
|
||||
std::string file_name;
|
||||
file_name.resize(MAX_PATH + 1U);
|
||||
file_name.resize(repertory::max_path_length + 1U);
|
||||
|
||||
::GetModuleFileNameA(nullptr, file_name.data(),
|
||||
static_cast<DWORD>(file_name.size() - 1U));
|
||||
|
@ -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;
|
||||
@ -55,7 +55,7 @@ namespace {
|
||||
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)
|
||||
}
|
||||
@ -70,12 +70,12 @@ namespace repertory::utils::file {
|
||||
// std::string path;
|
||||
//
|
||||
// #if defined(_WIN32)
|
||||
// path.resize(repertory::max_path_length + 1);
|
||||
// path.resize(repertory::max_path_length + 1U);
|
||||
// ::GetFinalPathNameByHandleA(handle, path.data(),
|
||||
// static_cast<DWORD>(path.size()),
|
||||
// FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
|
||||
// #else // !defined(_WIN32)
|
||||
// path.resize(repertory::max_path_length + 1);
|
||||
// path.resize(repertory::max_path_length + 1U);
|
||||
//
|
||||
// #if defined(__APPLE__)
|
||||
// fcntl(handle, F_GETPATH, source_path.data());
|
||||
@ -155,8 +155,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)
|
||||
|
@ -94,7 +94,7 @@ auto absolute(std::string_view path) -> std::string {
|
||||
}
|
||||
|
||||
std::string temp;
|
||||
temp.resize(repertory::max_path_length + 1);
|
||||
temp.resize(repertory::max_path_length + 1U);
|
||||
::GetFullPathNameA(abs_path.c_str(), static_cast<DWORD>(temp.size()),
|
||||
temp.data(), nullptr);
|
||||
#else // !defined(_WIN32)
|
||||
@ -206,8 +206,8 @@ auto get_parent_path(std::wstring_view path) -> std::wstring {
|
||||
get_parent_path(utils::string::to_utf8(path)));
|
||||
}
|
||||
|
||||
auto get_relative_path(std::string_view path,
|
||||
std::string_view root_path) -> std::string {
|
||||
auto get_relative_path(std::string_view path, std::string_view root_path)
|
||||
-> std::string {
|
||||
auto abs_path = absolute(path);
|
||||
auto abs_root_path =
|
||||
absolute(root_path) + std::string{get_directory_seperator<char>()};
|
||||
@ -223,8 +223,8 @@ auto get_relative_path(std::string_view path,
|
||||
return abs_path;
|
||||
}
|
||||
|
||||
auto get_relative_path(std::wstring_view path,
|
||||
std::wstring_view root_path) -> std::wstring {
|
||||
auto get_relative_path(std::wstring_view path, std::wstring_view root_path)
|
||||
-> std::wstring {
|
||||
return utils::string::from_utf8(get_relative_path(
|
||||
utils::string::to_utf8(path), utils::string::to_utf8(root_path)));
|
||||
}
|
||||
|
@ -116,7 +116,8 @@ auto run_process_elevated(std::vector<const char *> args) -> int {
|
||||
std::string full_path;
|
||||
full_path.resize(repertory::max_path_length + 1);
|
||||
|
||||
if (::GetModuleFileNameA(nullptr, full_path.data(), MAX_PATH)) {
|
||||
if (::GetModuleFileNameA(nullptr, full_path.data(),
|
||||
repertory::max_path_length)) {
|
||||
SHELLEXECUTEINFOA sei{};
|
||||
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
|
||||
sei.cbSize = sizeof(sei);
|
||||
|
Reference in New Issue
Block a user