refactor
This commit is contained in:
parent
857dcc5535
commit
924b79add2
@ -39,11 +39,12 @@ public:
|
||||
: mount_location_(std::move(mount_location)) {}
|
||||
|
||||
private:
|
||||
const std::string mount_location_;
|
||||
std::string mount_location_;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto get_directory_item_count(
|
||||
const std::string & /*api_path*/) const -> std::uint64_t override {
|
||||
[[nodiscard]] auto
|
||||
get_directory_item_count(const std::string & /*api_path*/) const
|
||||
-> std::uint64_t override {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -54,13 +55,12 @@ public:
|
||||
directory_item di{};
|
||||
di.api_path = ".";
|
||||
di.directory = true;
|
||||
di.size = 0u;
|
||||
di.meta = {
|
||||
{META_ATTRIBUTES, "16"},
|
||||
{META_MODIFIED, std::to_string(utils::time::get_time_now())},
|
||||
{META_WRITTEN, std::to_string(utils::time::get_time_now())},
|
||||
{META_ACCESSED, std::to_string(utils::time::get_time_now())},
|
||||
{META_CREATION, std::to_string(utils::time::get_time_now())}};
|
||||
di.size = 0U;
|
||||
di.meta = {{META_ATTRIBUTES, "16"},
|
||||
{META_MODIFIED, std::to_string(utils::time::get_time_now())},
|
||||
{META_WRITTEN, std::to_string(utils::time::get_time_now())},
|
||||
{META_ACCESSED, std::to_string(utils::time::get_time_now())},
|
||||
{META_CREATION, std::to_string(utils::time::get_time_now())}};
|
||||
list.emplace_back(di);
|
||||
|
||||
di.api_path = "..";
|
||||
@ -75,7 +75,7 @@ public:
|
||||
}
|
||||
|
||||
auto get_item_meta(const std::string & /*api_path*/,
|
||||
api_meta_map &meta) const -> api_error override {
|
||||
api_meta_map & /* meta */) const -> api_error override {
|
||||
return api_error::error;
|
||||
}
|
||||
|
||||
@ -85,19 +85,19 @@ public:
|
||||
return api_error::error;
|
||||
}
|
||||
|
||||
auto
|
||||
get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes,
|
||||
PSECURITY_DESCRIPTOR descriptor,
|
||||
std::uint64_t *descriptor_size) -> NTSTATUS override {
|
||||
auto get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes,
|
||||
PSECURITY_DESCRIPTOR descriptor,
|
||||
std::uint64_t *descriptor_size)
|
||||
-> NTSTATUS override {
|
||||
auto ret = STATUS_SUCCESS;
|
||||
|
||||
if (attributes) {
|
||||
if (attributes != nullptr) {
|
||||
*attributes = FILE_ATTRIBUTE_NORMAL;
|
||||
}
|
||||
|
||||
if (descriptor_size) {
|
||||
ULONG sz = 0;
|
||||
PSECURITY_DESCRIPTOR sd = nullptr;
|
||||
ULONG sz{0U};
|
||||
PSECURITY_DESCRIPTOR sd{nullptr};
|
||||
if (::ConvertStringSecurityDescriptorToSecurityDescriptor(
|
||||
"O:BAG:BAD:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;FA;;;WD)",
|
||||
SDDL_REVISION_1, &sd, &sz)) {
|
||||
@ -117,21 +117,21 @@ public:
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_total_drive_space() const -> std::uint64_t override {
|
||||
return 100 * 1024 * 1024;
|
||||
return 100ULL * 1024ULL * 1024ULL;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_total_item_count() const -> std::uint64_t override {
|
||||
return 0;
|
||||
return 0U;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto get_used_drive_space() const -> std::uint64_t override {
|
||||
return 0;
|
||||
return 0U;
|
||||
}
|
||||
|
||||
void get_volume_info(UINT64 &total_size, UINT64 &free_size,
|
||||
std::string &volume_label) const override {
|
||||
free_size = 100;
|
||||
total_size = 200;
|
||||
free_size = 100U;
|
||||
total_size = 200U;
|
||||
volume_label = "TestVolumeLabel";
|
||||
}
|
||||
|
||||
@ -162,10 +162,10 @@ public:
|
||||
WINFSP_ALLOCATION_UNIT) *
|
||||
WINFSP_ALLOCATION_UNIT;
|
||||
file_info.FileAttributes = fi.FileAttributes;
|
||||
file_info.ChangeTime = fi.ChangeTime.QuadPart;
|
||||
file_info.CreationTime = fi.CreationTime.QuadPart;
|
||||
file_info.LastAccessTime = fi.LastAccessTime.QuadPart;
|
||||
file_info.LastWriteTime = fi.LastWriteTime.QuadPart;
|
||||
file_info.ChangeTime = static_cast<UINT64>(fi.ChangeTime.QuadPart);
|
||||
file_info.CreationTime = static_cast<UINT64>(fi.CreationTime.QuadPart);
|
||||
file_info.LastAccessTime = static_cast<UINT64>(fi.LastAccessTime.QuadPart);
|
||||
file_info.LastWriteTime = static_cast<UINT64>(fi.LastWriteTime.QuadPart);
|
||||
::CloseHandle(handle);
|
||||
return api_error::success;
|
||||
}
|
||||
|
@ -436,15 +436,17 @@ static void set_basic_info_test(remote_client &client) {
|
||||
const auto change_time = last_write_time;
|
||||
#endif
|
||||
|
||||
EXPECT_EQ(STATUS_SUCCESS,
|
||||
client.winfsp_set_basic_info(file_desc, attributes, creation_time,
|
||||
last_access_time, last_write_time,
|
||||
change_time, &fi));
|
||||
EXPECT_EQ(static_cast<std::uint32_t>(attributes), fi.FileAttributes);
|
||||
EXPECT_EQ(creation_time, fi.CreationTime);
|
||||
EXPECT_EQ(last_access_time, fi.LastAccessTime);
|
||||
EXPECT_EQ(last_write_time, fi.LastWriteTime);
|
||||
EXPECT_EQ(change_time, fi.ChangeTime);
|
||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_set_basic_info(
|
||||
file_desc, static_cast<UINT32>(attributes),
|
||||
static_cast<UINT64>(creation_time),
|
||||
static_cast<UINT64>(last_access_time),
|
||||
static_cast<UINT64>(last_write_time),
|
||||
static_cast<UINT64>(change_time), &fi));
|
||||
EXPECT_EQ(static_cast<UINT32>(attributes), fi.FileAttributes);
|
||||
EXPECT_EQ(static_cast<UINT64>(creation_time), fi.CreationTime);
|
||||
EXPECT_EQ(static_cast<UINT64>(last_access_time), fi.LastAccessTime);
|
||||
EXPECT_EQ(static_cast<UINT64>(last_write_time), fi.LastWriteTime);
|
||||
EXPECT_EQ(static_cast<UINT64>(change_time), fi.ChangeTime);
|
||||
|
||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user