From ec2ff87ac70003ae8c7ed9ea81d9e878f6df21f0 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Mon, 4 Nov 2024 13:43:59 -0600 Subject: [PATCH] winfsp unit tests and fixes --- .../src/winfsp_drive_info_test.cpp | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/repertory/repertory_test/src/winfsp_drive_info_test.cpp b/repertory/repertory_test/src/winfsp_drive_info_test.cpp index 0bd12fdb..a4aaaab7 100644 --- a/repertory/repertory_test/src/winfsp_drive_info_test.cpp +++ b/repertory/repertory_test/src/winfsp_drive_info_test.cpp @@ -103,6 +103,35 @@ TYPED_TEST(winfsp_test, info_can_get_standard_info) { ::CloseHandle(handle); } + +TYPED_TEST(winfsp_test, info_can_get_file_name_info) { + auto file_path{ + utils::path::combine(this->mount_location, {"test_file_2"}), + }; + auto handle = + ::CreateFileA(file_path.c_str(), GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, 0, CREATE_NEW, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, 0); + ASSERT_NE(INVALID_HANDLE_VALUE, handle); + + std::array name_info{}; + EXPECT_TRUE( + ::GetFileInformationByHandleEx(handle, FileNameInfo, name_info.data(), + static_cast(name_info.size()))); + + auto *info = reinterpret_cast(name_info.data()); + auto expected_name{ + std::string{"\\repertory\\"} + std::string::to_lower(this->mount_location).at(0U)) + + "\\test_file_2", + }; + + EXPECT_EQ(info->FileNameLength, + static_cast(expected_name.size() * 2U)); + EXPECT_STREQ(expected_name.c_str(), + utils::string::to_utf8(info->FileName).c_str()); + + ::CloseHandle(handle); +} } // namespace repertory #endif // defined(_WIN32)